Lines
100.00%
4 / 4
Functions and Methods
100.00%
4 / 4
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| AppIdsFragment | 100.00% | 4 / 4 | 100.00% | 4 / 4 | 4 | 100.00% | 1 / 1 | |||
| __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 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Ipc\Wire; | |
| 6 | ||
| 7 | use Stewart\Contracts\App\AppId; | |
| 8 | use Stewart\Contracts\App\Collection\AppIdCollection; | |
| 9 | use Stewart\Runtime\Json\JsonFragment; | |
| 10 | use Stewart\Runtime\Json\WireMapper; | |
| 11 | use Stewart\Support\Json\JsonEncoder; | |
| 12 | ||
| 13 | final readonly class AppIdsFragment implements JsonFragment | |
| 14 | { | |
| 15 | private function __construct(public AppIdCollection $collection) {} | |
| 16 | ||
| 17 | public static function fromCollection(AppIdCollection $appIds): self | |
| 18 | { | |
| 19 | return new self($appIds); | |
| 20 | } | |
| 21 | ||
| 22 | public static function fromDecodedValue(mixed $value, string $path, WireMapper $mapper): static | |
| 23 | { | |
| 24 | return new self(AppIdCollection::fromList($mapper->decodeObjectList(AppId::class, $value, $path))); | |
| 25 | } | |
| 26 | ||
| 27 | public function encodeToJson(WireMapper $mapper): string | |
| 28 | { | |
| 29 | return JsonEncoder::encodeToJson($this->collection->toStrings()); | |
| 30 | } | |
| 31 | } |