-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathTargetPhpVersion.php
More file actions
50 lines (40 loc) · 948 Bytes
/
TargetPhpVersion.php
File metadata and controls
50 lines (40 loc) · 948 Bytes
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
<?php
declare(strict_types=1);
namespace Arkitect\CLI;
use Arkitect\Exceptions\PhpVersionNotValidException;
class TargetPhpVersion
{
public const VALID_PHP_VERSIONS = [
'7.1',
'7.2',
'7.3',
'7.4',
'8.0',
'8.1',
];
/** @var string|null */
private $version;
private function __construct(?string $version)
{
$this->version = $version;
}
/**
* @param ?string $version
*
* @throws PhpVersionNotValidException
*/
public static function create(?string $version = null): self
{
if (null === $version) {
return new self(phpversion());
}
if (!\in_array($version, (new self(null))::VALID_PHP_VERSIONS)) {
throw new PhpVersionNotValidException($version);
}
return new self($version);
}
public function get(): ?string
{
return $this->version;
}
}