Total Complexity | 5 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | class Priority |
||
15 | { |
||
16 | public const VERY_LOW = -2; |
||
17 | |||
18 | public const LOW = -1; |
||
19 | |||
20 | public const DEFAULT = 0; |
||
21 | |||
22 | public const HIGH = 1; |
||
23 | |||
24 | public const VERY_HIGH = 2; |
||
25 | |||
26 | /** @var int */ |
||
27 | private int $priority; |
||
28 | |||
29 | /** |
||
30 | * Priority constructor. |
||
31 | * @param int $value |
||
32 | */ |
||
33 | 45 | public function __construct(int $value) |
|
34 | { |
||
35 | 45 | if (in_array($value, self::getPriorities(), true) === false) { |
|
36 | 1 | throw new InvalidArgumentException(sprintf('"%s" is not a valid message priority.', $value)); |
|
37 | } |
||
38 | |||
39 | 44 | $this->priority = $value; |
|
40 | 44 | } |
|
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | 17 | public function __toString(): string |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return int |
||
52 | */ |
||
53 | 5 | public function getValue(): int |
|
54 | { |
||
55 | 5 | return $this->priority; |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return array |
||
60 | */ |
||
61 | 45 | public static function getPriorities(): array |
|
69 | ]; |
||
70 | } |
||
71 | } |
||
72 |