Skip to content

Commit

Permalink
Rename CI\Env to Environment + fix type compatibility with PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Feb 12, 2021
1 parent 8f16b08 commit 9745c18
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/Ci/AbstractCi.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*/
abstract class AbstractCi implements CiInterface
{
protected Env $env;
protected Environment $env;


public function __construct(Env $env)
public function __construct(Environment $env)
{
$this->env = $env;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Ci/AppVeyor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class AppVeyor extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('APPVEYOR') === 'True';
return $environment->get('APPVEYOR') === 'True';
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Bamboo.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Bamboo extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('bamboo_buildKey') !== false;
return $environment->get('bamboo_buildKey') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Buddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Buddy extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('BUDDY') !== false;
return $environment->get('BUDDY') !== false;
}


Expand Down
2 changes: 1 addition & 1 deletion src/Ci/CiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface CiInterface
/**
* Return true if this CI was detected
*/
public function isDetected(Env $env): bool;
public function isDetected(Environment $environment): bool;

/**
* Get name of the CI server type
Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Circle.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Circle extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('CIRCLECI') !== false;
return $environment->get('CIRCLECI') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Codeship.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Codeship extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('CI_NAME') === 'codeship';
return $environment->get('CI_NAME') === 'codeship';
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Continuousphp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Continuousphp extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('CONTINUOUSPHP') === 'continuousphp';
return $environment->get('CONTINUOUSPHP') === 'continuousphp';
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Drone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Drone extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('CI') === 'drone';
return $environment->get('CI') === 'drone';
}


Expand Down
12 changes: 6 additions & 6 deletions src/Ci/Env.php → src/Ci/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
/**
* Encapsulate access to the environment variables
*/
class Env
final class Environment
{
/**
* @return string|false Environment variable value or false if the variable does not exist
*/
public function get(string $name)
/** Environment variable value or false if the variable does not exist. */
public function get(string $name): string|false
{
return getenv($name);
$env = getenv($name);

return \is_array($env) === true ? false : $env;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/GitHubActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class GitHubActions extends AbstractCi
public const GITHUB_BASE_URL = 'https://github.com';


public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('GITHUB_ACTIONS') !== false;
return $environment->get('GITHUB_ACTIONS') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/GitLab.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class GitLab extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('GITLAB_CI') !== false;
return $environment->get('GITLAB_CI') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Jenkins.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Jenkins extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('JENKINS_URL') !== false;
return $environment->get('JENKINS_URL') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/TeamCity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class TeamCity extends AbstractCi
{
public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('TEAMCITY_VERSION') !== false;
return $environment->get('TEAMCITY_VERSION') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/Ci/Travis.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Travis extends AbstractCi
public const TRAVIS_BASE_URL = 'https://travis-ci.org';


public function isDetected(Env $env): bool
public function isDetected(Environment $environment): bool
{
return $env->get('TRAVIS') !== false;
return $environment->get('TRAVIS') !== false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/CiDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ final class CiDetector

public const CI_TRAVIS = 'Travis CI';

private Env $environment;
private Environment $environment;


public function __construct()
{
$this->environment = new Env;
$this->environment = new Environment;
}


Expand Down

0 comments on commit 9745c18

Please sign in to comment.