/**
* (non-PHPdoc)
*
* @see \Doctrine\DBAL\Types\Type::convertToPHPValue()
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
$matches = array();
preg_match('/(?:(?P<y>[0-9]+) (?:year|years))?' . ' ?(?:(?P<m>[0-9]+) (?:months|month|mons|mon))?' . ' ?(?:(?P<d>[0-9]+) (?:days|day))?' . ' ?(?:(?P<h>[0-9]{2}):(?P<i>[0-9]{2}):(?P<s>[0-9]{2}))?/i', $value, $matches);
if (empty($matches)) {
throw ConversionException::conversionFailed($value, self::NAME);
}
$interval = new Interval('PT0S');
if (!empty($matches['y'])) {
$interval->y = intval($matches['y']);
}
if (!empty($matches['m'])) {
$interval->m = intval($matches['m']);
}
if (!empty($matches['d'])) {
$interval->d = intval($matches['d']);
}
if (!empty($matches['h'])) {
$interval->h = intval($matches['h']);
}
if (!empty($matches['i'])) {
$interval->i = intval($matches['i']);
}
if (!empty($matches['s'])) {
$interval->s = intval($matches['s']);
}
return $interval;
}