Browse Source

fixed V convert types: minOccurs, maxOccurs

Piotr Labudda 8 years ago
parent
commit
1bee72ca64
1 changed files with 9 additions and 6 deletions
  1. 9 6
      SE/se-lib/V.php

+ 9 - 6
SE/se-lib/V.php

@@ -61,6 +61,15 @@ class V {
 	 * @usage: V::convert($from, 'url');
 	 */
 	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);
 
 		// is_scalar($from) - return TRUE if int,float,string,bool, FALSE if array,object,resource, ...
@@ -168,12 +177,6 @@ class V {
 				return $ret;
 			case 'bool':
 			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:
 				$fun = 'func_type_convert_'.$type;
 				return (function_exists($fun)) ? $fun($from) : null;