for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* LICENSE: This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
*
* @copyright 2016 Copyright(c) - All rights reserved.
*/
namespace Rafrsr\LibArray2Object\Parser;
class DateTimeParser implements ValueParserInterface
{
const NAME = 'datetime';
* @inheritDoc
public function getName()
return self::NAME;
}
public function toObjectValue($value, $type, \ReflectionProperty $property, $object)
if (is_string($value) && ($type === 'DateTime' || $type === '\DateTime')) {
return new \DateTime($value);
return $value;
public function toArrayValue($value, $type, \ReflectionProperty $property, $object)
if ($value instanceof \DateTime) {
return $value->format('c');