Total Complexity | 8 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
8 | final class MaxFrameSize |
||
9 | { |
||
10 | private $value; |
||
11 | |||
12 | 134 | public function __construct(int $value) |
|
13 | { |
||
14 | 134 | if ($value < 0 || ($value !== 0 && $value < 9)) { |
|
15 | 18 | throw new DomainException; |
|
16 | } |
||
17 | |||
18 | 116 | $this->value = $value; |
|
19 | 116 | } |
|
20 | |||
21 | 112 | public function isLimited(): bool |
|
22 | { |
||
23 | 112 | return $this->value > 0; |
|
24 | } |
||
25 | |||
26 | 92 | public function allows(int $size): bool |
|
27 | { |
||
28 | 92 | if (!$this->isLimited()) { |
|
29 | 92 | return true; |
|
30 | } |
||
31 | |||
32 | 92 | return $size <= $this->value; |
|
33 | } |
||
34 | |||
35 | 102 | public function toInt(): int |
|
38 | } |
||
39 | } |
||
40 |