From bbe6b5b15b523ff7ca50feaffce30004e746146d Mon Sep 17 00:00:00 2001 From: rojaro <> Date: Fri, 9 Apr 2010 13:38:35 +0000 Subject: added ensureNullIfEmpty converter --- framework/TComponent.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'framework') diff --git a/framework/TComponent.php b/framework/TComponent.php index 647653dd..55c19ecf 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -801,6 +801,16 @@ class TPropertyValue else throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums)); } + + /** + * Converts the value to 'null' if the given value is empty + * @param mixed value to be converted + * @return mixed input or NULL if input is empty + */ + public static function ensureNullIfEmpty($value) + { + return empty($value) ? null : $value; + } } /** -- cgit v1.2.3