diff options
author | alex <> | 2005-11-17 11:47:30 +0000 |
---|---|---|
committer | alex <> | 2005-11-17 11:47:30 +0000 |
commit | b4f41b167b62bb628d0809fc0e9438e11dce2bb5 (patch) | |
tree | af0ef1912ad48db33b2d0db94419378fd5627125 /framework | |
parent | 6c1b05deafd9940da5d473800032558df90b118e (diff) |
Updated TPropertyValue so ensureArray parses a string like "(aaa,bbb,ccc)" into array("aaa","bbb","ccc"). Also added PradoUnitTestCase which is to be finalized shortly.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/TComponent.php | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/framework/TComponent.php b/framework/TComponent.php index 8df1f235..04c99f2a 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -490,13 +490,29 @@ class TPropertyValue }
/**
- * Converts a value to array type.
+ * Converts a value to array type. If the value is a string and it is
+ * in the form (a,b,c) then an array consisting of each of the elements
+ * will be returned. If the value is a string and it is not in this form
+ * then an array consisting of just the string will be returned. If the value
+ * is not a string then
* @param mixed the value to be converted.
* @return array
*/
public static function ensureArray($value)
{
- return (array)$value;
+ if (is_string($value)) {
+ $trimmed = trim($value);
+ $len = strlen($value);
+ if ($len >= 2 && $trimmed{0} == '(' && $trimmed{$len-1} == ')') {
+ return explode(",", substr($trimmed,1,$len-2));
+ } else if ($len > 0) {
+ return array($value);
+ } else {
+ return array();
+ }
+ } else {
+ return (array)$value;
+ }
}
/**
|