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
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Health;
6
7use JsonException;
8use Stewart\Contracts\Exception\StewartException;
9use Stewart\Runtime\Json\ClassShapeReader;
10use Stewart\Runtime\Json\Collection\ValueConverterCollection;
11use Stewart\Runtime\Json\WireMapper;
12
13final 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}