mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
fix denormalization of invalid dates
This commit is contained in:
parent
51dc255be5
commit
f47fb17b8d
@ -44,13 +44,21 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
|
|||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case DateTime::class:
|
case DateTime::class:
|
||||||
return DateTime::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']);
|
$result = DateTime::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']);
|
||||||
|
break;
|
||||||
|
|
||||||
case DateTimeInterface::class:
|
case DateTimeInterface::class:
|
||||||
case DateTimeImmutable::class:
|
case DateTimeImmutable::class:
|
||||||
return DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']);
|
$result = DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false === $result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
throw new UnexpectedValueException();
|
throw new UnexpectedValueException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user