-
-
Notifications
You must be signed in to change notification settings - Fork 365
/
Environment.php
56 lines (45 loc) · 1.02 KB
/
Environment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments;
/**
* @internal
*/
final class Environment implements HandlesArguments
{
/**
* The continuous integration environment.
*/
public const CI = 'ci';
/**
* The local environment.
*/
public const LOCAL = 'local';
/**
* The current environment.
*/
private static ?string $name = null;
/**
* {@inheritdoc}
*/
public function handleArguments(array $arguments): array
{
foreach ($arguments as $index => $argument) {
if ($argument === '--ci') {
unset($arguments[$index]);
self::$name = self::CI;
}
}
return array_values($arguments);
}
/**
* Gets the environment name.
*/
public static function name(?string $name = null): string
{
if (is_string($name)) {
self::$name = $name;
}
return self::$name ?? self::LOCAL;
}
}