Total Complexity | 7 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 61.53% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class StatusCode |
||
22 | { |
||
23 | /** @var int */ |
||
24 | private $statusCode; |
||
25 | |||
26 | 8 | public function __construct(int $statusCode) |
|
27 | { |
||
28 | 8 | $this->ensureIsValidStatusCode($statusCode); |
|
29 | 8 | $this->statusCode = $statusCode; |
|
30 | 8 | } |
|
31 | |||
32 | public static function createDefault(): self |
||
33 | { |
||
34 | return new self(200); |
||
35 | } |
||
36 | |||
37 | 8 | public function asInt(): int |
|
38 | { |
||
39 | 8 | return $this->statusCode; |
|
40 | } |
||
41 | |||
42 | public function equals(self $other): bool |
||
43 | { |
||
44 | return $this->asInt() === $other->asInt(); |
||
45 | } |
||
46 | |||
47 | 8 | private function ensureIsValidStatusCode(int $statusCode) |
|
51 | } |
||
52 | 8 | } |
|
53 | } |
||
54 |