|
@@ -61,6 +61,15 @@ class V {
|
|
|
* @usage: V::convert($from, 'url');
|
|
* @usage: V::convert($from, 'url');
|
|
|
*/
|
|
*/
|
|
|
public static function convert($from, $type = 'string') {
|
|
public static function convert($from, $type = 'string') {
|
|
|
|
|
+ switch ($type) {
|
|
|
|
|
+ case 'minOccurs':
|
|
|
|
|
+ case 'maxOccurs': // The default values for minOccurs and maxOccurs are 1 - @return int or 'unbounded', default is 1
|
|
|
|
|
+ if (!is_scalar($from)) return null;
|
|
|
|
|
+ if (!strlen($from)) return 1;
|
|
|
|
|
+ if ("unbounded" === $from) return "unbounded";
|
|
|
|
|
+ return (int)$from;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$type = strtolower($type);
|
|
$type = strtolower($type);
|
|
|
|
|
|
|
|
// is_scalar($from) - return TRUE if int,float,string,bool, FALSE if array,object,resource, ...
|
|
// is_scalar($from) - return TRUE if int,float,string,bool, FALSE if array,object,resource, ...
|
|
@@ -168,12 +177,6 @@ class V {
|
|
|
return $ret;
|
|
return $ret;
|
|
|
case 'bool':
|
|
case 'bool':
|
|
|
case 'boolean': return (bool)$from;
|
|
case 'boolean': return (bool)$from;
|
|
|
- case 'minOccurs':
|
|
|
|
|
- case 'maxOccurs': // The default values for minOccurs and maxOccurs are 1 - @return int or 'unbounded', default is 1
|
|
|
|
|
- if (!is_scalar($from)) return null;
|
|
|
|
|
- if (!strlen($from)) return 1;
|
|
|
|
|
- if ("unbounded" === $from) return "unbounded";
|
|
|
|
|
- return (int)$from;
|
|
|
|
|
default:
|
|
default:
|
|
|
$fun = 'func_type_convert_'.$type;
|
|
$fun = 'func_type_convert_'.$type;
|
|
|
return (function_exists($fun)) ? $fun($from) : null;
|
|
return (function_exists($fun)) ? $fun($from) : null;
|