Total Complexity | 7 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class ApiStatus { |
||
7 | |||
8 | /** |
||
9 | * @var string |
||
10 | */ |
||
11 | private $serviceName; |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $status; |
||
17 | |||
18 | 5 | public function __construct(string $serviceName, string $status) { |
|
19 | 5 | $this->serviceName = $serviceName; |
|
20 | 5 | $this->status = $status; |
|
21 | 5 | } |
|
22 | |||
23 | 2 | public function getServiceName(): string { |
|
24 | 2 | return $this->serviceName; |
|
25 | } |
||
26 | |||
27 | 5 | public function getStatus(): string { |
|
28 | 5 | return $this->status; |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * Asserts that current service has no issues. |
||
33 | * |
||
34 | * @return bool |
||
35 | */ |
||
36 | 3 | public function isGreen(): bool { |
|
37 | 3 | return $this->assertStatusIs('green'); |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Asserts that current service has some issues. |
||
42 | * |
||
43 | * @return bool |
||
44 | */ |
||
45 | 3 | public function isYellow(): bool { |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Asserts that current service is unavailable. |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | 3 | public function isRed(): bool { |
|
56 | } |
||
57 | |||
58 | 3 | private function assertStatusIs(string $expectedStatus): bool { |
|
59 | 3 | return $this->getStatus() === $expectedStatus; |
|
63 |