From 479523842b2f38207d03bd136e711e65b885f815 Mon Sep 17 00:00:00 2001 From: Dmitry Chubar Date: Mon, 6 Mar 2023 21:18:08 +0100 Subject: [PATCH] String to DateTime mapping --- src/JsonMapper.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/JsonMapper.php b/src/JsonMapper.php index 8bfdb7c..36cef03 100644 --- a/src/JsonMapper.php +++ b/src/JsonMapper.php @@ -242,6 +242,12 @@ private function mapValue( } } + foreach ($parameterType->types as $type) { + if ($type->name == \DateTime::class) { + return new \DateTime($jsonValue); + } + } + // TODO "Parameter %s of class %s does not accept string" + JSON path throw new JsonMapperException('Property ' . $jsonPropertyName . ' cannot be a string.'); }