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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ProbeReportCodec | 100.00% | 3 / 3 | 100.00% | 3 / 3 | 3 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| createProbeReportWireMapper | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| encodeReport | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Health; | |
| 6 | ||
| 7 | use JsonException; | |
| 8 | use Stewart\Contracts\Exception\StewartException; | |
| 9 | use Stewart\Runtime\Json\ClassShapeReader; | |
| 10 | use Stewart\Runtime\Json\Collection\ValueConverterCollection; | |
| 11 | use Stewart\Runtime\Json\WireMapper; | |
| 12 | ||
| 13 | final readonly class ProbeReportCodec | |
| 14 | { | |
| 15 | public function __construct(private WireMapper $probeReportWireMapper) {} | |
| 16 | ||
| 17 | public static function createProbeReportWireMapper(): WireMapper | |
| 18 | { | |
| 19 | return new WireMapper(new ClassShapeReader(ValueConverterCollection::keyedByHandledClass([]))); | |
| 20 | } | |
| 21 | ||
| 22 | /** @throws JsonException|StewartException */ | |
| 23 | public function encodeReport(ProbeReport $report): string | |
| 24 | { | |
| 25 | return $this->probeReportWireMapper->encodeObject($report); | |
| 26 | } | |
| 27 | } |