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