Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| DateTimeToString | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
3.33 | |
0.00% |
0 / 1 |
| convert | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
3.33 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadata\Converters; |
| 3 | |
| 4 | use Apie\TypeConverter\ConverterInterface; |
| 5 | use DateTimeInterface; |
| 6 | use ReflectionType; |
| 7 | |
| 8 | /** |
| 9 | * @implements ConverterInterface<DateTimeInterface, string> |
| 10 | */ |
| 11 | class DateTimeToString implements ConverterInterface |
| 12 | { |
| 13 | public function convert(?DateTimeInterface $input, ?ReflectionType $wantedType): ?string |
| 14 | { |
| 15 | if ($input === null && $wantedType->allowsNull()) { |
| 16 | return null; |
| 17 | } |
| 18 | return $input->format(DateTimeInterface::ATOM); |
| 19 | } |
| 20 | } |