Total Complexity | 5 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 0 |
1 | <?php |
||
5 | final class Status |
||
6 | { |
||
7 | const WAITING = 'waiting', |
||
8 | RUNNING = 'running', |
||
9 | FINISHED = 'finished', |
||
10 | FAILED = 'failed'; |
||
11 | |||
12 | /** |
||
13 | * |
||
14 | * @var |
||
15 | */ |
||
16 | private $value; |
||
17 | |||
18 | /** |
||
19 | * |
||
20 | * @param $value |
||
21 | * @throws \Exception |
||
22 | */ |
||
23 | 31 | public function __construct($value) |
|
24 | { |
||
25 | 31 | if (!in_array($value, self::listStatus(), true)) { |
|
26 | 1 | throw new \RuntimeException(sprintf('Status "%s" does not exists', $value)); |
|
27 | } |
||
28 | |||
29 | 30 | $this->value = $value; |
|
30 | 30 | } |
|
31 | |||
32 | /** |
||
33 | * |
||
34 | * @return mixed |
||
35 | */ |
||
36 | public function getValue() |
||
37 | { |
||
38 | return $this->value; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | 32 | public static function listStatus(): array |
|
52 | ]; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | 21 | public function __toString() |
|
62 | } |
||
63 | } |
||
64 |