src/Normalizer/NullableDateTimeDenormalizer.php line 19

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Normalizer;
  3. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  4. readonly class NullableDateTimeDenormalizer implements DenormalizerInterface
  5. {
  6. public function __construct(
  7. private DenormalizerInterface $dateTimeNormalizer
  8. ) {
  9. }
  10. public function denormalize($data, string $type, string $format = null, array $context = []): null
  11. {
  12. return null;
  13. }
  14. public function supportsDenormalization($data, string $type, string $format = null): bool
  15. {
  16. if ($data === '' || $data === null) {
  17. return $this->dateTimeNormalizer->supportsDenormalization($data, $type, $format);
  18. }
  19. return false;
  20. }
  21. }