Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ValueObjectToFloat | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
convert | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 |
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, float> |
11 | */ |
12 | class ValueObjectToFloat implements ConverterInterface |
13 | { |
14 | public function convert(ValueObjectInterface $input, ?ReflectionType $wantedType): ?float |
15 | { |
16 | $native = $input->toNative(); |
17 | if (null === $native && $wantedType?->allowsNull()) { |
18 | return null; |
19 | } |
20 | return Utils::toFloat($native); |
21 | } |
22 | } |