Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MixedToMixedStorage | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |
0.00% |
0 / 1 |
| convert | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadata\Converters; |
| 3 | |
| 4 | use Apie\Core\Utils\ConverterUtils; |
| 5 | use Apie\StorageMetadataBuilder\Interfaces\MixedStorageInterface; |
| 6 | use Apie\TypeConverter\ConverterInterface; |
| 7 | use ReflectionType; |
| 8 | |
| 9 | /** |
| 10 | * @implements ConverterInterface<mixed, MixedStorageInterface> |
| 11 | */ |
| 12 | class MixedToMixedStorage implements ConverterInterface |
| 13 | { |
| 14 | public function convert(mixed $input, ?ReflectionType $wantedType): ?MixedStorageInterface |
| 15 | { |
| 16 | $class = ConverterUtils::toReflectionClass($wantedType); |
| 17 | assert(null !== $class); |
| 18 | $className = $class->name; |
| 19 | if ($input === null && $wantedType?->allowsNull()) { |
| 20 | return null; |
| 21 | } |
| 22 | return new $className($input); |
| 23 | } |
| 24 | } |