| Total Complexity | 10 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class StatusChecker implements StatusCheckerInterface, LoggerAwareInterface |
||
| 9 | { |
||
| 10 | |||
| 11 | use LoggerAwareTrait; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * registered ungrouped checks |
||
| 15 | * @var StatusCheckerGroup |
||
| 16 | */ |
||
| 17 | protected $ungroupedChecks; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var StatusCheckerGroup[] |
||
| 21 | */ |
||
| 22 | protected $results = []; |
||
| 23 | |||
| 24 | public function addCheck(CheckInterface $checker): void |
||
| 25 | { |
||
| 26 | if ($this->ungroupedChecks === null) { |
||
| 27 | $this->ungroupedChecks = new StatusCheckerGroup(''); |
||
| 28 | $this->addGroup($this->ungroupedChecks); |
||
| 29 | } |
||
| 30 | $this->ungroupedChecks->addCheck($checker); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function addGroup(StatusCheckerGroup $group): void |
||
| 34 | { |
||
| 35 | if ($this->logger) { |
||
| 36 | $group->setLogger($this->logger); |
||
| 37 | } |
||
| 38 | $this->results[] = $group; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function check(): void |
||
| 42 | { |
||
| 43 | foreach($this->results as $group) { |
||
| 44 | $group->check(); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | public function getResults(): array |
||
| 49 | { |
||
| 50 | return $this->results; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function hasErrors(): bool |
||
| 63 | } |
||
| 64 | } |
||
| 65 |