mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +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) {
|
||||
case DateTime::class:
|
||||
return DateTime::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']);
|
||||
$result = DateTime::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']);
|
||||
break;
|
||||
|
||||
case DateTimeInterface::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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user