Commit 35a4dfb2 authored by Marco Pivetta's avatar Marco Pivetta

#869 - DBAL-1293 - simplified conversion logic for readability (TimeType)

parent 9f72045a
......@@ -49,12 +49,15 @@ class TimeType extends Type
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value !== null && !$value instanceof \DateTime) {
throw ConversionException::conversionFailedInvalidType($value, $this->getName(), "DateTime");
if (null === $value) {
return $value;
}
if ($value instanceof \DateTime) {
return $value->format($platform->getTimeFormatString());
}
return ($value !== null)
? $value->format($platform->getTimeFormatString()) : null;
throw ConversionException::conversionFailedInvalidType($value, $this->getName(), 'DateTime');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment