Completed
Pull Request — master (#5)
by Boy
14:52 queued 04:17
created
src/CMPayments/SchemaValidator/SchemaValidator.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -381,9 +381,9 @@
 block discarded – undo
381 381
     /**
382 382
      * Validate $schema->$property
383 383
      *
384
-     * @param array      $input
384
+     * @param string[]      $input
385 385
      * @param            $schema
386
-     * @param            $path
386
+     * @param            string $path
387 387
      * @param bool|false $mandatory
388 388
      *
389 389
      * @return mixed
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
      */
536 536
     private function validateSchemaRequiredAgainstProperties($schema, $path)
537 537
     {
538
-        $requiredPath = $path . '.required';
538
+        $requiredPath = $path.'.required';
539 539
 
540 540
         // $schema->required must be an array
541 541
         if (!is_array($schema->required)) {
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 
746 746
                     $data = str_replace("\n", '', $data);
747 747
                     $data = preg_replace("/\r|\n/", '', $data);
748
-                    $data = (strlen($data) < 25) ? $data : substr($data, 0, 25) . ' [...]';
748
+                    $data = (strlen($data) < 25) ? $data : substr($data, 0, 25).' [...]';
749 749
                 }
750 750
 
751 751
                 // boolean handling
Please login to merge, or discard this patch.
src/CMPayments/SchemaValidator/Exceptions/ValidateSchemaException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,6 +67,6 @@
 block discarded – undo
67 67
      */
68 68
     public function getItemFromVariableArray($code, $default = null, $msgArray = 'messages')
69 69
     {
70
-        return (new \ReflectionClass($this))->getShortName() . ': ' . parent::getItemFromVariableArray($code, $default, $msgArray);
70
+        return (new \ReflectionClass($this))->getShortName().': '.parent::getItemFromVariableArray($code, $default, $msgArray);
71 71
     }
72 72
 }
Please login to merge, or discard this patch.