diff --git a/src/Common/Hydrator/Strategy/NullValueStrategy.php b/src/Common/Hydrator/Strategy/NullValueStrategy.php new file mode 100644 index 0000000..a6418d3 --- /dev/null +++ b/src/Common/Hydrator/Strategy/NullValueStrategy.php @@ -0,0 +1,60 @@ + + * @copyright 2013 Jurian Sluiman. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://soflomo.com + */ + +namespace Soflomo\Common\Hydrator\Strategy; + +use Zend\Stdlib\Hydrator\Strategy\DefaultStrategy; + +class NullValueStrategy extends DefaultStrategy +{ + /** + * {@inheritdoc} + * + * Convert an empty string value into null + */ + public function hydrate($value) + { + if (is_string($value) && $value === '') { + $value = null; + } + + return $value; + } +} \ No newline at end of file