@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $filename = $cache->getFilename(); |
| 68 | 68 | if (empty($filename)) { |
| 69 | 69 | |
| 70 | - $cache->setFilename(md5(json_encode($schema)) . '.php'); |
|
| 70 | + $cache->setFilename(md5(json_encode($schema)).'.php'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // if cache file exists, require it, if not, validate the schema |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | || (!isset($schema->additionalProperties) && (isset($this->rootSchema->additionalProperties) && !$this->rootSchema->additionalProperties)) |
| 150 | 150 | ) { |
| 151 | 151 | // $schema->additionalProperties says NO, log that a fields is missing |
| 152 | - $this->addError(ValidateException::ERROR_USER_DATA_PROPERTY_IS_NOT_AN_ALLOWED_PROPERTY, [$path . '/' . $property]); |
|
| 152 | + $this->addError(ValidateException::ERROR_USER_DATA_PROPERTY_IS_NOT_AN_ALLOWED_PROPERTY, [$path.'/'.$property]); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | // Everything else |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | public function validate($schema, $property, $data, $path) |
| 173 | 173 | { |
| 174 | 174 | // check if the expected $schema->type matches gettype($data) |
| 175 | - $type = $this->validateType($schema, $data, ((substr($path, -1) !== '/') ? $path . '/' . $property : $path . $property)); |
|
| 175 | + $type = $this->validateType($schema, $data, ((substr($path, -1) !== '/') ? $path.'/'.$property : $path.$property)); |
|
| 176 | 176 | |
| 177 | 177 | // append /$property to $path |
| 178 | - $path .= (substr($path, 0, 1) !== '/') ? '/' . $property : $property; |
|
| 178 | + $path .= (substr($path, 0, 1) !== '/') ? '/'.$property : $property; |
|
| 179 | 179 | |
| 180 | 180 | // if $type is an object |
| 181 | 181 | if ($type === BaseValidator::OBJECT) { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | && ($schema->type === $type) |
| 187 | 187 | ) { // everything else except boolean |
| 188 | 188 | |
| 189 | - $method = 'validate' . ucfirst($type); |
|
| 189 | + $method = 'validate'.ucfirst($type); |
|
| 190 | 190 | $this->$method($data, $schema, $path); |
| 191 | 191 | |
| 192 | 192 | // check for format property on schema |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | // check if the given schema is not empty |
| 249 | 249 | if (empty($schemaPropertiesInArray)) { |
| 250 | 250 | |
| 251 | - throw new ValidateSchemaException(ValidateSchemaException::ERROR_SCHEMA_CANNOT_BE_EMPTY_IN_PATH, [$path . '/properties']); |
|
| 251 | + throw new ValidateSchemaException(ValidateSchemaException::ERROR_SCHEMA_CANNOT_BE_EMPTY_IN_PATH, [$path.'/properties']); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | foreach ($schema->properties as $property => $childSchema) { |
| 255 | 255 | |
| 256 | - $subPath = $path . '.properties'; |
|
| 256 | + $subPath = $path.'.properties'; |
|
| 257 | 257 | |
| 258 | 258 | // when an object key is empty it becomes '_empty_' by json_decode(), catch it since this is not valid |
| 259 | 259 | if ($property === '_empty_') { |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | 'Schema', |
| 271 | 271 | $this->getPreposition(gettype($childSchema)), |
| 272 | 272 | gettype($childSchema), |
| 273 | - (' in ' . $subPath) |
|
| 273 | + (' in '.$subPath) |
|
| 274 | 274 | ]); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // do recursion |
| 278 | - $schema->properties->$property = $this->validateSchema($childSchema, ($subPath . '.' . $property)); |
|
| 278 | + $schema->properties->$property = $this->validateSchema($childSchema, ($subPath.'.'.$property)); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // check if the optional property 'required' is set on $schema |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | } elseif ($schema->type === BaseValidator::_ARRAY) { |
| 288 | 288 | |
| 289 | 289 | // do recursion |
| 290 | - $schema->items = $this->validateSchema($schema->items, ($path . '.items')); |
|
| 290 | + $schema->items = $this->validateSchema($schema->items, ($path.'.items')); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return $schema; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // check if $expected contains the $property |
| 466 | - $values = (array) $schema->$property; |
|
| 466 | + $values = (array)$schema->$property; |
|
| 467 | 467 | foreach ($values as $value) { |
| 468 | 468 | if (!in_array($value, $expected)) { |
| 469 | 469 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | private function validateSchemaRequiredAgainstProperties($schema, $path) |
| 516 | 516 | { |
| 517 | - $requiredPath = $path . '.required'; |
|
| 517 | + $requiredPath = $path.'.required'; |
|
| 518 | 518 | |
| 519 | 519 | // $schema->required must be an array |
| 520 | 520 | if (!is_array($schema->required)) { |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | // check if given type matches the expected type, if not add verbose error |
| 698 | 698 | $type = strtolower($type); |
| 699 | - $types = (array) $schema->type; |
|
| 699 | + $types = (array)$schema->type; |
|
| 700 | 700 | if (!in_array($type, $types)) { |
| 701 | 701 | |
| 702 | 702 | $msg = ValidateException::ERROR_USER_DATA_VALUE_DOES_NOT_MATCH_CORRECT_TYPE_1; |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | $data = str_replace("\n", '', $data); |
| 712 | 712 | $data = preg_replace("/\r|\n/", '', $data); |
| 713 | - $data = (strlen($data) < 25) ? $data : substr($data, 0, 25) . ' [...]'; |
|
| 713 | + $data = (strlen($data) < 25) ? $data : substr($data, 0, 25).' [...]'; |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | $params[] = $data; |
@@ -29,6 +29,6 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function getItemFromVariableArray($code, $default = null, $msgArray = 'messages') |
| 31 | 31 | { |
| 32 | - return (new \ReflectionClass($this))->getShortName() . ': ' . parent::getItemFromVariableArray($code, $default, $msgArray); |
|
| 32 | + return (new \ReflectionClass($this))->getShortName().': '.parent::getItemFromVariableArray($code, $default, $msgArray); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getPreposition($type) |
| 87 | 87 | { |
| 88 | - $types = (array) $type; |
|
| 88 | + $types = (array)$type; |
|
| 89 | 89 | $type = strtolower($types[0]); |
| 90 | 90 | |
| 91 | 91 | if (!isset($this->prepositions[$type])) { |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | if (in_array(($lastDigit = (int)substr($number, -1)), [1, 2, 3])) { |
| 142 | 142 | |
| 143 | - return $number . $this->stringifiedOrdinals[$lastDigit]; |
|
| 143 | + return $number.$this->stringifiedOrdinals[$lastDigit]; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - return $number . $this->stringifiedOrdinals[0]; |
|
| 146 | + return $number.$this->stringifiedOrdinals[0]; |
|
| 147 | 147 | } |
| 148 | 148 | } |