Lines
100.00%
3 / 3
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| SnapshotProbeReporter | 100.00% | 3 / 3 | 100.00% | 2 / 2 | 4 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| reportProbe | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 3 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Health; | |
| 6 | ||
| 7 | use Stewart\Runtime\Control\SnapshotSource; | |
| 8 | ||
| 9 | final readonly class SnapshotProbeReporter implements ProbeReporter | |
| 10 | { | |
| 11 | public function __construct( | |
| 12 | private SnapshotSource $snapshots, | |
| 13 | private ReadinessCheck $readiness, | |
| 14 | ) {} | |
| 15 | ||
| 16 | public function reportProbe(ProbeKind $kind): ProbeReport | |
| 17 | { | |
| 18 | return match ($kind) { | |
| 19 | ProbeKind::Liveness => ProbeReport::alive(), | |
| 20 | ProbeKind::Readiness => ProbeReport::fromVerdict($this->readiness->assessSnapshot($this->snapshots->takeSnapshot())), | |
| 21 | }; | |
| 22 | } | |
| 23 | } |