Skip to content

Commit

Permalink
Minor optimization for DateTimeType
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 31, 2016
1 parent 445e0cc commit 2d153f0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Database/Type/DateTimeType.php
Expand Up @@ -121,6 +121,10 @@ public function toPHP($value, Driver $driver)
list($value) = explode('.', $value);
}

if ($this->_datetimeInstance === null) {
$this->_datetimeInstance = new $this->_className;
}

$instance = clone $this->_datetimeInstance;
return $instance->modify($value);
}
Expand Down Expand Up @@ -251,7 +255,7 @@ protected function _setClassName($class, $fallback)
$class = $fallback;
}
$this->_className = $class;
$this->_datetimeInstance = new $this->_className;
$this->_datetimeInstance = null;
}

/**
Expand Down

0 comments on commit 2d153f0

Please sign in to comment.