Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
AutoIncrementTableToValueObject | |
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\ValueObjects\Interfaces\ValueObjectInterface; |
5 | use Apie\StorageMetadata\Interfaces\AutoIncrementTableInterface; |
6 | use Apie\TypeConverter\ConverterInterface; |
7 | use Apie\TypeConverter\TypeConverter; |
8 | use ReflectionType; |
9 | |
10 | /** |
11 | * @implements ConverterInterface<AutoIncrementTableInterface, ?ValueObjectInterface> |
12 | */ |
13 | class 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 | } |