Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | final class Priority |
||
8 | { |
||
9 | const LOWEST = 1; |
||
10 | const LOW = 3; |
||
11 | const NORMAL = 5; |
||
12 | const HIGH = 7; |
||
13 | const URGENT = 9; |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | private $value; |
||
19 | |||
20 | 17 | public function __construct(int $priority) |
|
21 | { |
||
22 | 17 | if (!$this->isValid($priority)) { |
|
23 | 4 | throw new InvalidPriorityException("Invalid priority: {$priority}."); |
|
24 | } |
||
25 | |||
26 | 13 | $this->value = $priority; |
|
27 | 13 | } |
|
28 | |||
29 | 8 | public function toInt(): int |
|
32 | } |
||
33 | |||
34 | 17 | private function isValid(int $priority): bool |
|
39 |