Lines
100.00%
3 / 3
Functions and Methods
100.00%
3 / 3
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ProbeReport | 100.00% | 3 / 3 | 100.00% | 3 / 3 | 4 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| alive | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| fromVerdict | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Health; | |
| 6 | ||
| 7 | use Stewart\Contracts\Wire\ListOf; | |
| 8 | ||
| 9 | final readonly class ProbeReport | |
| 10 | { | |
| 11 | /** @param list<string> $reasons */ | |
| 12 | public function __construct( | |
| 13 | public ProbeStatus $status, | |
| 14 | #[ListOf('string')] | |
| 15 | public array $reasons, | |
| 16 | ) {} | |
| 17 | ||
| 18 | public static function alive(): self | |
| 19 | { | |
| 20 | return new self(ProbeStatus::Alive, []); | |
| 21 | } | |
| 22 | ||
| 23 | public static function fromVerdict(ReadinessVerdict $verdict): self | |
| 24 | { | |
| 25 | return new self($verdict->isReady() ? ProbeStatus::Ready : ProbeStatus::NotReady, $verdict->unreadyReasons); | |
| 26 | } | |
| 27 | } |