| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 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 | public function __construct(string $serviceName, string $status) { |
||
| 19 | $this->serviceName = $serviceName; |
||
| 20 | $this->status = $status; |
||
| 21 | } |
||
| 22 | |||
| 23 | public function getServiceName(): string { |
||
| 24 | return $this->serviceName; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function getStatus(): string { |
||
| 28 | return $this->status; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Asserts that current service has no issues. |
||
| 33 | * |
||
| 34 | * @return bool |
||
| 35 | */ |
||
| 36 | public function isGreen(): bool { |
||
| 37 | return $this->assertStatusIs('green'); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Asserts that current service has some issues. |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public function isYellow(): bool { |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Asserts that current service is unavailable. |
||
| 51 | * |
||
| 52 | * @return bool |
||
| 53 | */ |
||
| 54 | public function isRed(): bool { |
||
| 56 | } |
||
| 57 | |||
| 58 | private function assertStatusIs(string $expectedStatus): bool { |
||
| 59 | return $this->getStatus() === $expectedStatus; |
||
| 63 |