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
EncodedStateUpdate 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\Runtime\Json\WireMapper;
10use Stewart\Support\State\StateUpdate;
11
12final class EncodedStateUpdate
13{
14    private ?string $json = null;
15
16    public function __construct(public readonly StateUpdate $update) {}
17
18    /** @throws JsonException|StewartException */
19    public function encodeToJson(WireMapper $mapper): string
20    {
21        return $this->json ??= $mapper->encodeObject($this->update);
22    }
23}