Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
StringToValueObject
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 convert
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\StorageMetadata\Converters;
3
4use Apie\Core\Utils\ConverterUtils;
5use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface;
6use Apie\TypeConverter\ConverterInterface;
7use ReflectionType;
8
9/**
10 * @implements ConverterInterface<string|null, ValueObjectInterface>
11 */
12class StringToValueObject implements ConverterInterface
13{
14    public function convert(?string $input, ?ReflectionType $wantedType): ValueObjectInterface
15    {
16        $class = ConverterUtils::toReflectionClass($wantedType);
17        assert(null !== $class);
18        $className = $class->name;
19        // @phpstan-ignore-next-line
20        return $className::fromNative($input);
21    }
22}