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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ValueConverterCollection | 100.00% | 2 / 2 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| keyedByHandledClass | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| findForClass | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Json\Collection; | |
| 6 | ||
| 7 | use Stewart\Contracts\Collection\KeyedCollection; | |
| 8 | use Stewart\Runtime\Json\ValueConverter; | |
| 9 | ||
| 10 | /** @extends KeyedCollection<string, ValueConverter> */ | |
| 11 | final readonly class ValueConverterCollection extends KeyedCollection | |
| 12 | { | |
| 13 | /** @param iterable<ValueConverter> $converters */ | |
| 14 | public static function keyedByHandledClass(iterable $converters): self | |
| 15 | { | |
| 16 | return self::keyedBy($converters, static fn(ValueConverter $converter): string => $converter->handledClass()); | |
| 17 | } | |
| 18 | ||
| 19 | public function findForClass(string $class): ?ValueConverter | |
| 20 | { | |
| 21 | return $this->elementAt($class); | |
| 22 | } | |
| 23 | } |