| Total Complexity | 5 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class StatusSection implements ApplicationStatus |
||
| 12 | { |
||
| 13 | public const DEFAULT_HEALTHY = 'Status: %s'; |
||
| 14 | public const DEFAULT_UNHEALTHY = 'Status: %s!'; |
||
| 15 | |||
| 16 | private string $healthy; |
||
| 17 | private string $unhealthy; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $healthy |
||
| 21 | * @param string $unhealthy |
||
| 22 | */ |
||
| 23 | public function __construct( |
||
| 24 | string $healthy = self::DEFAULT_HEALTHY, |
||
| 25 | string $unhealthy = self::DEFAULT_UNHEALTHY |
||
| 26 | ) { |
||
| 27 | $this->healthy = $healthy; |
||
| 28 | $this->unhealthy = $unhealthy; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @inheritDoc |
||
| 33 | */ |
||
| 34 | public function format(HealthCheck $healthCheck, SymfonyStyle $styler): void |
||
| 35 | { |
||
| 36 | $styler->section('Application Health'); |
||
| 37 | if ($healthCheck->isHealthy()) { |
||
| 38 | $styler->success($this->getHealthy()); |
||
| 39 | } else { |
||
| 40 | $styler->warning($this->getUnhealthy()); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | private function getHealthy(): string |
||
| 48 | { |
||
| 49 | return sprintf($this->healthy, self::STATUS_HEALTHY); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | private function getUnhealthy(): string |
||
| 58 | } |
||
| 59 | } |
||
| 60 |