@@ -37,18 +37,18 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $db->drop($this->collection_name, $this->schema); |
| 39 | 39 | $db->create($this->collection_name, $this->schema); |
| 40 | - $indexes =[]; |
|
| 40 | + $indexes = []; |
|
| 41 | 41 | foreach ($this->schema as $field=>$fconfig) { |
| 42 | 42 | if ($fconfig['_index'] === true) { |
| 43 | 43 | $index = ['key'=>[$field=>1]]; |
| 44 | 44 | if (isset($fconfig["_index_type"])) { |
| 45 | 45 | switch ($fconfig["_index_type"]) { |
| 46 | 46 | case 'unique': |
| 47 | - $index['unique']=true; |
|
| 47 | + $index['unique'] = true; |
|
| 48 | 48 | break; |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | - $indexes[]=$index; |
|
| 51 | + $indexes[] = $index; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | if ($this->data_file !== null) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | - if (count($indexes) > 0) { |
|
| 64 | + if (count($indexes)>0) { |
|
| 65 | 65 | $db->create_indexes($this->collection_name, $indexes); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -91,8 +91,7 @@ discard block |
||
| 91 | 91 | if (ModelUtils::gettype($my_doc[$key]) != "array") { |
| 92 | 92 | return $my_doc[$key]; |
| 93 | 93 | } |
| 94 | - } |
|
| 95 | - elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] !="array") { |
|
| 94 | + } elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] !="array") { |
|
| 96 | 95 | $my_doc[$key]=$my_model[$key]['_default']; |
| 97 | 96 | } |
| 98 | 97 | // If array[key] is not an array and not has same variable type that stated in the model definition . |
@@ -129,20 +128,17 @@ discard block |
||
| 129 | 128 | case 'date': |
| 130 | 129 | if ($my_model[$key]['_default']=='today') { |
| 131 | 130 | $new_doc[$key] = date("Y-m-d"); |
| 132 | - } |
|
| 133 | - else { |
|
| 131 | + } else { |
|
| 134 | 132 | $new_doc[$key]=$my_model[$key]['_default']; |
| 135 | 133 | } |
| 136 | 134 | break; |
| 137 | 135 | case 'timestamp': |
| 138 | 136 | if (($my_model[$key]['_default']=="now") && ($my_model[$key]['_type'] == "integer")) { |
| 139 | 137 | $new_doc[$key] = time(); |
| 140 | - } |
|
| 141 | - else if ($my_model[$key]['_default']=="now" && ($my_model[$key]['_type']=="string")) { |
|
| 138 | + } else if ($my_model[$key]['_default']=="now" && ($my_model[$key]['_type']=="string")) { |
|
| 142 | 139 | |
| 143 | 140 | $new_doc[$key] = date("Y-m-d H:i:s"); |
| 144 | - } |
|
| 145 | - else { |
|
| 141 | + } else { |
|
| 146 | 142 | $new_doc[$key]=$my_model[$key]['_default']; |
| 147 | 143 | } |
| 148 | 144 | break; |
@@ -150,8 +146,7 @@ discard block |
||
| 150 | 146 | default: |
| 151 | 147 | $new_doc[$key]=$my_model[$key]['_default']; |
| 152 | 148 | } |
| 153 | - } |
|
| 154 | - else { |
|
| 149 | + } else { |
|
| 155 | 150 | $new_doc[$key]=$my_model[$key]['_default']; |
| 156 | 151 | } |
| 157 | 152 | } |
@@ -29,16 +29,16 @@ discard block |
||
| 29 | 29 | // Does doc has a array that does not exist in model definition . |
| 30 | 30 | if (!isset($my_model[$key])) { |
| 31 | 31 | if ($my_key !== null) { |
| 32 | - $my_key = strval($my_key) . " . " . strval($key); |
|
| 32 | + $my_key = strval($my_key)." . ".strval($key); |
|
| 33 | 33 | } else { |
| 34 | 34 | $my_key = $key; |
| 35 | 35 | } |
| 36 | - throw new \Exception("Error for key '" . $my_key . "' that does not exist in the model"); |
|
| 36 | + throw new \Exception("Error for key '".$my_key."' that does not exist in the model"); |
|
| 37 | 37 | } |
| 38 | 38 | // Is the value of the array[key] again another array? . |
| 39 | 39 | elseif (ModelUtils::gettype($my_doc[$key]) == "array") { |
| 40 | 40 | if ($my_key !== null) { |
| 41 | - $my_key = strval($my_key) . " . " . strval($key); |
|
| 41 | + $my_key = strval($my_key)." . ".strval($key); |
|
| 42 | 42 | } else { |
| 43 | 43 | $my_key = $key; |
| 44 | 44 | } |
@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | // Does the value of the array[key] have same variable type that stated in the definition of the model array . |
| 52 | 52 | elseif (ModelUtils::gettype($my_doc[$key]) != $my_model[$key]['_type']) { |
| 53 | 53 | if ($my_key !== null) { |
| 54 | - $my_key = $my_key . " . " . $key; |
|
| 54 | + $my_key = $my_key." . ".$key; |
|
| 55 | 55 | } else { |
| 56 | 56 | $my_key = $key; |
| 57 | 57 | } |
| 58 | - throw new \Exception("Error for key '" . $my_key . "'" . ", " . ModelUtils::gettype($my_doc[$key]) . |
|
| 59 | - " given but it must be " . $my_model[$key]['_type']); |
|
| 58 | + throw new \Exception("Error for key '".$my_key."'".", ".ModelUtils::gettype($my_doc[$key]). |
|
| 59 | + " given but it must be ".$my_model[$key]['_type']); |
|
| 60 | 60 | } else { |
| 61 | 61 | if ($my_key !== null) { |
| 62 | - $v_key = $my_key . " . " . $key; |
|
| 62 | + $v_key = $my_key." . ".$key; |
|
| 63 | 63 | } else { |
| 64 | 64 | $v_key = $key; |
| 65 | 65 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $my_keys = array_keys($my_doc); |
| 82 | 82 | foreach ($my_keys as $key) { |
| 83 | 83 | // If array has a key that is not presented in the model definition, unset it . |
| 84 | - if (! isset($my_model[$key])) { |
|
| 84 | + if (!isset($my_model[$key])) { |
|
| 85 | 85 | unset($my_doc[$key]); |
| 86 | 86 | } |
| 87 | 87 | // If array[$key] is again an array, recursively fit this array too . |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | return $my_doc[$key]; |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | - elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] !="array") { |
|
| 96 | - $my_doc[$key]=$my_model[$key]['_default']; |
|
| 95 | + elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] != "array") { |
|
| 96 | + $my_doc[$key] = $my_model[$key]['_default']; |
|
| 97 | 97 | } |
| 98 | 98 | // If array[key] is not an array and not has same variable type that stated in the model definition . |
| 99 | 99 | else { |
@@ -113,46 +113,46 @@ discard block |
||
| 113 | 113 | public static function setting_model_defaults($my_model, $my_doc) |
| 114 | 114 | { |
| 115 | 115 | $my_keys = array_keys($my_model); |
| 116 | - $new_doc =[ ]; |
|
| 116 | + $new_doc = []; |
|
| 117 | 117 | foreach ($my_keys as $key) { |
| 118 | 118 | $item_keys = array_keys($my_model[$key]); |
| 119 | 119 | // If one of the keys of $my_model[$key] is _type this is a definition, not a defined key |
| 120 | 120 | if (in_array("_type", $item_keys)) { |
| 121 | 121 | // If array does not have this key, set the default value . |
| 122 | - if (! isset($my_doc[$key])) { |
|
| 122 | + if (!isset($my_doc[$key])) { |
|
| 123 | 123 | if (isset($my_model[$key]['_input_type'])) { |
| 124 | 124 | switch ($my_model[$key]['_input_type']) { |
| 125 | 125 | case 'uid': |
| 126 | 126 | $shortid = ShortId::create(); |
| 127 | - $new_doc[$key]=$shortid->generate(); |
|
| 127 | + $new_doc[$key] = $shortid->generate(); |
|
| 128 | 128 | break; |
| 129 | 129 | case 'date': |
| 130 | - if ($my_model[$key]['_default']=='today') { |
|
| 130 | + if ($my_model[$key]['_default'] == 'today') { |
|
| 131 | 131 | $new_doc[$key] = date("Y-m-d"); |
| 132 | 132 | } |
| 133 | 133 | else { |
| 134 | - $new_doc[$key]=$my_model[$key]['_default']; |
|
| 134 | + $new_doc[$key] = $my_model[$key]['_default']; |
|
| 135 | 135 | } |
| 136 | 136 | break; |
| 137 | 137 | case 'timestamp': |
| 138 | - if (($my_model[$key]['_default']=="now") && ($my_model[$key]['_type'] == "integer")) { |
|
| 138 | + if (($my_model[$key]['_default'] == "now") && ($my_model[$key]['_type'] == "integer")) { |
|
| 139 | 139 | $new_doc[$key] = time(); |
| 140 | 140 | } |
| 141 | - else if ($my_model[$key]['_default']=="now" && ($my_model[$key]['_type']=="string")) { |
|
| 141 | + else if ($my_model[$key]['_default'] == "now" && ($my_model[$key]['_type'] == "string")) { |
|
| 142 | 142 | |
| 143 | 143 | $new_doc[$key] = date("Y-m-d H:i:s"); |
| 144 | 144 | } |
| 145 | 145 | else { |
| 146 | - $new_doc[$key]=$my_model[$key]['_default']; |
|
| 146 | + $new_doc[$key] = $my_model[$key]['_default']; |
|
| 147 | 147 | } |
| 148 | 148 | break; |
| 149 | 149 | |
| 150 | 150 | default: |
| 151 | - $new_doc[$key]=$my_model[$key]['_default']; |
|
| 151 | + $new_doc[$key] = $my_model[$key]['_default']; |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | else { |
| 155 | - $new_doc[$key]=$my_model[$key]['_default']; |
|
| 155 | + $new_doc[$key] = $my_model[$key]['_default']; |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | // If array has this key |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | // If model definition stated this key's default value is not Null and has a wrong variable type, fix it . |
| 161 | 161 | if ($my_model[$key]['_default'] !== null) { |
| 162 | 162 | if (ModelUtils::gettype($my_doc[$key]) != $my_model[$key]['_type'] && ModelUtils::gettype($my_doc[$key]) == "array") { |
| 163 | - $my_doc[$key]=$my_model[$key]['_default']; |
|
| 163 | + $my_doc[$key] = $my_model[$key]['_default']; |
|
| 164 | 164 | } |
| 165 | 165 | settype($my_doc[$key], $my_model[$key]['_type']); |
| 166 | 166 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | // If one of the keys is not _type, this is a defined key, recursively get sub keys . |
| 172 | 172 | else { |
| 173 | - if (! isset($my_doc[$key])) { |
|
| 173 | + if (!isset($my_doc[$key])) { |
|
| 174 | 174 | $my_doc[$key] = ""; |
| 175 | 175 | } |
| 176 | 176 | $new_doc[$key] = ModelUtils::setting_model_defaults($my_model[$key], $my_doc[$key]); |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public static function validate_doc_item($value, $my_model, $key) |
| 191 | 191 | { |
| 192 | - $type = isset($my_model['_type']) ? $my_model['_type'] : 'string'; |
|
| 193 | - $input_type = isset($my_model['_input_type']) ? $my_model['_input_type'] : 'string'; |
|
| 192 | + $type = isset($my_model['_type']) ? $my_model['_type'] : 'string'; |
|
| 193 | + $input_type = isset($my_model['_input_type']) ? $my_model['_input_type'] : 'string'; |
|
| 194 | 194 | $format = isset($my_model['_input_format']) ? $my_model['_input_format'] : ""; |
| 195 | - $min_length = isset($my_model['_min_length']) ? $my_model['_min_length'] : null; |
|
| 196 | - $max_length = isset($my_model['_max_length']) ? $my_model['_max_length'] : null; |
|
| 197 | - $in_options = isset($my_model['_in_options']) ? $my_model['_in_options'] : null; |
|
| 195 | + $min_length = isset($my_model['_min_length']) ? $my_model['_min_length'] : null; |
|
| 196 | + $max_length = isset($my_model['_max_length']) ? $my_model['_max_length'] : null; |
|
| 197 | + $in_options = isset($my_model['_in_options']) ? $my_model['_in_options'] : null; |
|
| 198 | 198 | |
| 199 | 199 | if (ModelUtils::gettype($value) != $type) { |
| 200 | 200 | return false; |
@@ -205,21 +205,21 @@ discard block |
||
| 205 | 205 | case 'mail': |
| 206 | 206 | $filter_check = filter_var($value, FILTER_VALIDATE_EMAIL); |
| 207 | 207 | if ($filter_check === false) { |
| 208 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 208 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 209 | 209 | "validation: INVALID_EMAIL_ADDRESS "); |
| 210 | 210 | } |
| 211 | 211 | break; |
| 212 | 212 | case 'bool': |
| 213 | 213 | $filter_check = filter_var($value, FILTER_VALIDATE_BOOLEAN); |
| 214 | 214 | if ($filter_check === false) { |
| 215 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 215 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 216 | 216 | "validation: INVALID_BOOLEAN_VALUE "); |
| 217 | 217 | } |
| 218 | 218 | break; |
| 219 | 219 | case 'url': |
| 220 | 220 | $filter_check = filter_var($value, FILTER_VALIDATE_URL); |
| 221 | 221 | if ($filter_check === false) { |
| 222 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 222 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 223 | 223 | "validation: INVALID_URL "); |
| 224 | 224 | } |
| 225 | 225 | break; |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | case 'ip': |
| 230 | 230 | $filter_check = filter_var($value, FILTER_VALIDATE_IP); |
| 231 | 231 | if ($filter_check === false) { |
| 232 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 232 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 233 | 233 | "validation: INVALID_IP_ADDRESS "); |
| 234 | 234 | } |
| 235 | 235 | break; |
| 236 | 236 | case 'mac_address': |
| 237 | 237 | $filter_check = filter_var($value, FILTER_VALIDATE_MAC); |
| 238 | 238 | if ($filter_check === false) { |
| 239 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 239 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 240 | 240 | "validation: INVALID_MAC_ADDRESS "); |
| 241 | 241 | } |
| 242 | 242 | break; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $regex = "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/"; |
| 245 | 245 | $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex))); |
| 246 | 246 | if ($filter_check === false) { |
| 247 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 247 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 248 | 248 | "validation: INVALID_FORMAT "); |
| 249 | 249 | } |
| 250 | 250 | break; |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $regex = "/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])$/"; |
| 253 | 253 | $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex))); |
| 254 | 254 | if ($filter_check === false) { |
| 255 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 255 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 256 | 256 | "validation: INVALID_FORMAT "); |
| 257 | 257 | } |
| 258 | 258 | break; |
@@ -260,14 +260,14 @@ discard block |
||
| 260 | 260 | $regex = "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) ([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])$/"; |
| 261 | 261 | $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex))); |
| 262 | 262 | if ($filter_check === false) { |
| 263 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the validation: INVALID_FORMAT "); |
|
| 263 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the validation: INVALID_FORMAT "); |
|
| 264 | 264 | } |
| 265 | 265 | break; |
| 266 | 266 | case 'regex': |
| 267 | - $regex = "/^" . $format . "$/"; |
|
| 267 | + $regex = "/^".$format."$/"; |
|
| 268 | 268 | $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex))); |
| 269 | 269 | if ($filter_check === false) { |
| 270 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 270 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 271 | 271 | "validation: INVALID_FORMAT "); |
| 272 | 272 | } |
| 273 | 273 | break; |
@@ -277,37 +277,37 @@ discard block |
||
| 277 | 277 | case 'integer': |
| 278 | 278 | case 'float': |
| 279 | 279 | if ($min_length !== null) { |
| 280 | - if ($value < $min_length) { |
|
| 281 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 282 | - "validation: Must be bigger than " . $min_length . " "); |
|
| 280 | + if ($value<$min_length) { |
|
| 281 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 282 | + "validation: Must be bigger than ".$min_length." "); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | if ($max_length !== null) { |
| 286 | - if ($value > $max_length) { |
|
| 287 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 288 | - "validation: Must be smallerr than " . $max_length . " "); |
|
| 286 | + if ($value>$max_length) { |
|
| 287 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 288 | + "validation: Must be smallerr than ".$max_length." "); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | break; |
| 292 | 292 | default: |
| 293 | 293 | if ($max_length !== null) { |
| 294 | - if (strlen($value) > $max_length) { |
|
| 295 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 296 | - "validation: It's length must be smaller than " . $max_length . " "); |
|
| 294 | + if (strlen($value)>$max_length) { |
|
| 295 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 296 | + "validation: It's length must be smaller than ".$max_length." "); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | if ($min_length !== null) { |
| 300 | - if (strlen($value) < $min_length) { |
|
| 301 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the " . |
|
| 302 | - "validation: It's length must be longer than " . $min_length . " "); |
|
| 300 | + if (strlen($value)<$min_length) { |
|
| 301 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ". |
|
| 302 | + "validation: It's length must be longer than ".$min_length." "); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | break; |
| 306 | 306 | } |
| 307 | 307 | if ($in_options !== null) { |
| 308 | 308 | if (!in_array($value, $in_options)) { |
| 309 | - throw new \Exception("Error for value '" . $value . "' for '" . $key . "' couldn't pass the validation: " . |
|
| 310 | - "It's length must be one of the these values: " . implode(", ", $in_options) . " "); |
|
| 309 | + throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the validation: ". |
|
| 310 | + "It's length must be one of the these values: ".implode(", ", $in_options)." "); |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
@@ -322,17 +322,17 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public static function sanitize_doc_item($value, $my_model) |
| 324 | 324 | { |
| 325 | - $type = isset($my_model['_type']) ? $my_model['_type'] : 'string'; |
|
| 326 | - $input_type = isset($my_model['_input_type']) ? $my_model['_input_type'] : null; |
|
| 325 | + $type = isset($my_model['_type']) ? $my_model['_type'] : 'string'; |
|
| 326 | + $input_type = isset($my_model['_input_type']) ? $my_model['_input_type'] : null; |
|
| 327 | 327 | $format = isset($my_model['_input_format']) ? $my_model['_input_format'] : ""; |
| 328 | - $min_length = isset($my_model['_min_length']) ? $my_model['_min_length'] : null; |
|
| 329 | - $max_length = isset($my_model['_max_length']) ? $my_model['_max_length'] : null; |
|
| 330 | - $in_options = isset($my_model['_in_options']) ? $my_model['_in_options'] : null; |
|
| 328 | + $min_length = isset($my_model['_min_length']) ? $my_model['_min_length'] : null; |
|
| 329 | + $max_length = isset($my_model['_max_length']) ? $my_model['_max_length'] : null; |
|
| 330 | + $in_options = isset($my_model['_in_options']) ? $my_model['_in_options'] : null; |
|
| 331 | 331 | |
| 332 | 332 | if ($input_type !== null) { |
| 333 | 333 | switch ($input_type) { |
| 334 | 334 | case 'timestamp': |
| 335 | - if ($value=='now') { |
|
| 335 | + if ($value == 'now') { |
|
| 336 | 336 | $value = time(); |
| 337 | 337 | } |
| 338 | 338 | break; |
@@ -350,19 +350,19 @@ discard block |
||
| 350 | 350 | case 'integer': |
| 351 | 351 | case 'float': |
| 352 | 352 | if ($min_length !== null) { |
| 353 | - if ($value < $min_length) { |
|
| 353 | + if ($value<$min_length) { |
|
| 354 | 354 | $value = $min_length; |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | if ($max_length !== null) { |
| 358 | - if ($value > $max_length) { |
|
| 358 | + if ($value>$max_length) { |
|
| 359 | 359 | $value = $max_length; |
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | break; |
| 363 | 363 | default: |
| 364 | 364 | if ($max_length !== null) { |
| 365 | - if (strlen($value) > $max_length) { |
|
| 365 | + if (strlen($value)>$max_length) { |
|
| 366 | 366 | $value = substr($value, 0, $max_length); |
| 367 | 367 | } |
| 368 | 368 | } |