Lines
100.00%
4 / 4
Methods
100.00%
4 / 4
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| fromCollection | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| fromDecodedValue | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| encodeToJson | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 12 | final class EntityStatesFragment implements JsonFragment | |
| 13 | { | |
| 14 | private ?string $json = null; | |
| 15 | ||
| 16 | private function __construct(public readonly EntityStateCollection $collection) {} | |
| 17 | ||
| 18 | public static function fromCollection(EntityStateCollection $states): self | |
| 19 | { | |
| 20 | return new self($states); | |
| 21 | } | |
| 22 | ||
| 23 | public static function fromDecodedValue(mixed $value, string $path, WireMapper $mapper): static | |
| 24 | { | |
| 25 | return new self(EntityStateCollection::keyedByEntityId($mapper->decodeObjectList(EntityState::class, $value, $path))); | |
| 26 | } | |
| 27 | ||
| 28 | public function encodeToJson(WireMapper $mapper): string | |
| 29 | { | |
| 30 | return $this->json ??= $mapper->encodeObjectList($this->collection->listValues()); | |
| 31 | } | |
| 32 | } |