Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
AutoIncrementTableToValueObject
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
3.04
0.00% covered (danger)
0.00%
0 / 1
 convert
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
3.04
1<?php
2namespace Apie\StorageMetadata\Converters;
3
4use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface;
5use Apie\StorageMetadata\Interfaces\AutoIncrementTableInterface;
6use Apie\TypeConverter\ConverterInterface;
7use Apie\TypeConverter\TypeConverter;
8use ReflectionType;
9
10/**
11 * @implements ConverterInterface<AutoIncrementTableInterface, ?ValueObjectInterface>
12 */
13class AutoIncrementTableToValueObject implements ConverterInterface
14{
15    public function convert(AutoIncrementTableInterface $input, ?ReflectionType $wantedType, ?TypeConverter $typeConverter = null): ?ValueObjectInterface
16    {
17        assert($typeConverter !== null);
18        assert($wantedType !== null);
19        $key = $input->getKey();
20        if ($key === null && $wantedType->allowsNull()) {
21            return null;
22        }
23        return $typeConverter->convertTo($key, $wantedType);
24    }
25}