Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ValueObjectToInt | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| convert | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadata\Converters; |
| 3 | |
| 4 | use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface; |
| 5 | use Apie\Core\ValueObjects\Utils; |
| 6 | use Apie\TypeConverter\ConverterInterface; |
| 7 | use ReflectionType; |
| 8 | |
| 9 | /** |
| 10 | * @implements ConverterInterface<ValueObjectInterface, int|null> |
| 11 | */ |
| 12 | class ValueObjectToInt implements ConverterInterface |
| 13 | { |
| 14 | public function convert(ValueObjectInterface $input, ?ReflectionType $wantedType): ?int |
| 15 | { |
| 16 | $native = $input->toNative(); |
| 17 | if (null === $native && $wantedType?->allowsNull()) { |
| 18 | return null; |
| 19 | } |
| 20 | return Utils::toInt($native); |
| 21 | } |
| 22 | } |