Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
MixedToMixedStorage
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 convert
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2namespace Apie\StorageMetadata\Converters;
3
4use Apie\Core\Utils\ConverterUtils;
5use Apie\StorageMetadataBuilder\Interfaces\MixedStorageInterface;
6use Apie\TypeConverter\ConverterInterface;
7use ReflectionType;
8
9/**
10 * @implements ConverterInterface<mixed, MixedStorageInterface>
11 */
12class 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}