Lines 100.00% 2 / 2
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
EncodedStateChange 100.00% 2 / 2 100.00% 2 / 2 2 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 encodeToJson 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Ipc\Wire;
6
7use JsonException;
8use Stewart\Contracts\Exception\StewartException;
9use Stewart\Contracts\State\StateChange;
10use Stewart\Runtime\Json\WireMapper;
11
12final class EncodedStateChange
13{
14    private ?string $json = null;
15
16    public function __construct(public readonly StateChange $change) {}
17
18    /** @throws JsonException|StewartException */
19    public function encodeToJson(WireMapper $mapper): string
20    {
21        return $this->json ??= $mapper->encodeObject($this->change);
22    }
23}