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