REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.77 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/ondram/ci-detector/src/CiDetector.php
Text
Base64
<?php declare (strict_types=1); namespace RectorPrefix202411\OndraM\CiDetector; use RectorPrefix202411\OndraM\CiDetector\Ci\CiInterface; use RectorPrefix202411\OndraM\CiDetector\Exception\CiNotDetectedException; /** * Unified way to get environment variables from current continuous integration server */ class CiDetector implements CiDetectorInterface { public const CI_APPVEYOR = 'AppVeyor'; public const CI_AWS_CODEBUILD = 'AWS CodeBuild'; public const CI_AZURE_PIPELINES = 'Azure Pipelines'; public const CI_BAMBOO = 'Bamboo'; public const CI_BITBUCKET_PIPELINES = 'Bitbucket Pipelines'; public const CI_BUDDY = 'Buddy'; public const CI_CIRCLE = 'CircleCI'; public const CI_CODESHIP = 'Codeship'; public const CI_CONTINUOUSPHP = 'continuousphp'; public const CI_DRONE = 'drone'; public const CI_GITHUB_ACTIONS = 'GitHub Actions'; public const CI_GITLAB = 'GitLab'; public const CI_JENKINS = 'Jenkins'; public const CI_SOURCEHUT = 'SourceHut'; public const CI_TEAMCITY = 'TeamCity'; public const CI_TRAVIS = 'Travis CI'; /** * @deprecated Will be removed in next major version */ public const CI_WERCKER = 'Wercker'; /** * @var \OndraM\CiDetector\Env */ private $environment; public final function __construct() { $this->environment = new Env(); } public static function fromEnvironment(Env $environment) : self { $detector = new static(); $detector->environment = $environment; return $detector; } public function isCiDetected() : bool { $ciServer = $this->detectCurrentCiServer(); return $ciServer !== null; } public function detect() : CiInterface { $ciServer = $this->detectCurrentCiServer(); if ($ciServer === null) { throw new CiNotDetectedException('No CI server detected in current environment'); } return $ciServer; } /** * @return string[] */ protected function getCiServers() : array { return [Ci\AppVeyor::class, Ci\AwsCodeBuild::class, Ci\AzurePipelines::class, Ci\Bamboo::class, Ci\BitbucketPipelines::class, Ci\Buddy::class, Ci\Circle::class, Ci\Codeship::class, Ci\Continuousphp::class, Ci\Drone::class, Ci\GitHubActions::class, Ci\GitLab::class, Ci\Jenkins::class, Ci\SourceHut::class, Ci\TeamCity::class, Ci\Travis::class, Ci\Wercker::class]; } protected function detectCurrentCiServer() : ?CiInterface { $ciServers = $this->getCiServers(); foreach ($ciServers as $ciClass) { $callback = [$ciClass, 'isDetected']; if (\is_callable($callback) && $callback($this->environment)) { return new $ciClass($this->environment); } } return null; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 4
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Ci
DIR
-
drwxr-xr-x
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Exception
DIR
-
drwxr-xr-x
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CiDetector.php
2.77 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CiDetectorInterface.php
630 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Env.php
455 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TrinaryLogic.php
1.83 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).