Total Complexity | 8 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class PlatformNullFile |
||
8 | { |
||
9 | public const PLATFORM_LINUX = 'LINUX'; |
||
10 | public const PLATFORM_WIN = 'WINDOWS'; |
||
11 | |||
12 | public const SUPPORTED_PLATFORMS = [ |
||
13 | self::PLATFORM_LINUX, |
||
14 | self::PLATFORM_WIN, |
||
15 | ]; |
||
16 | |||
17 | /** @var string $platform if null platform wil be auto detected */ |
||
18 | protected $platform; |
||
19 | |||
20 | /** |
||
21 | * @param null|string $platform if null platform will be autodetected |
||
22 | * |
||
23 | * @throws \InvalidArgumentException |
||
24 | */ |
||
25 | public function __construct(?string $platform = null) |
||
26 | { |
||
27 | if ($platform === null) { |
||
28 | $platform = self::getCurrentPlatform(); |
||
29 | } else { |
||
30 | if (in_array(mb_strtoupper($platform), self::SUPPORTED_PLATFORMS, true)) { |
||
31 | throw new \InvalidArgumentException(sprintf( |
||
32 | 'Platform \'%s\' is not supported', |
||
33 | $platform |
||
34 | )); |
||
35 | } |
||
36 | } |
||
37 | $this->platform = mb_strtoupper($platform); |
||
38 | } |
||
39 | |||
40 | public static function getCurrentPlatform(): string |
||
44 | } |
||
45 | |||
46 | public function getNullFile(): string |
||
55 | } |
||
56 | } |
||
58 |