Passed
Push — master ( 5de612...863f0a )
by Darío
01:40
created
src/Validator/FormValidator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -304,7 +304,7 @@
 block discarded – undo
304 304
             {
305 305
                 foreach ($validator->getMessages() as $message)
306 306
                 {
307
-                    $this->error($label ."-~-". (count($this->getErrors()) + 1), $message);
307
+                    $this->error($label . "-~-" . (count($this->getErrors()) + 1), $message);
308 308
                 }
309 309
             }
310 310
         }
Please login to merge, or discard this patch.
Braces   +37 added lines, -28 removed lines patch added patch discarded remove patch
@@ -69,9 +69,10 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function isValid()
71 71
     {
72
-        if (is_null($this->valid))
73
-            # This error is thrown because of 'setValid' method has not been executed.
72
+        if (is_null($this->valid)) {
73
+                    # This error is thrown because of 'setValid' method has not been executed.
74 74
             throw new \LogicException('No validation has been executed!');
75
+        }
75 76
 
76 77
         return $this->valid;
77 78
     }
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
     {
99 100
         $this->form = $form;
100 101
 
101
-        if (is_null($locale))
102
-            $locale = 'en';
102
+        if (is_null($locale)) {
103
+                    $locale = 'en';
104
+        }
103 105
 
104 106
         $i18nTranslator = \Zend\I18n\Translator\Translator::factory(
105 107
             [
@@ -133,8 +135,9 @@  discard block
 block discarded – undo
133 135
 
134 136
         foreach ($elements as $label => $element)
135 137
         {
136
-            if (!$element->isFormControl())
137
-                continue;
138
+            if (!$element->isFormControl()) {
139
+                            continue;
140
+            }
138 141
 
139 142
             $attribs = $element->getAttributes();
140 143
 
@@ -203,19 +206,21 @@  discard block
 block discarded – undo
203 206
 
204 207
                     case 'min':
205 208
 
206
-                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range']))
207
-                            $validator = new GreaterThan(['min' => $value, 'inclusive' => true]);
208
-                        else
209
-                            throw new \LogicException("The input type must be 'range' or 'number'");
209
+                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) {
210
+                                                    $validator = new GreaterThan(['min' => $value, 'inclusive' => true]);
211
+                        } else {
212
+                                                    throw new \LogicException("The input type must be 'range' or 'number'");
213
+                        }
210 214
 
211 215
                         break;
212 216
 
213 217
                     case 'max':
214 218
 
215
-                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range']))
216
-                            $validator = new LessThan(['max' => $value, 'inclusive' => true]);
217
-                        else
218
-                            throw new \LogicException("The input type must be 'range' or 'number'");
219
+                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) {
220
+                                                    $validator = new LessThan(['max' => $value, 'inclusive' => true]);
221
+                        } else {
222
+                                                    throw new \LogicException("The input type must be 'range' or 'number'");
223
+                        }
219 224
 
220 225
                         break;
221 226
 
@@ -223,17 +228,19 @@  discard block
 block discarded – undo
223 228
 
224 229
                         $baseValue = (array_key_exists('min', $all_attribs)) ? $all_attribs['min'] : 0;
225 230
 
226
-                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range']))
227
-                            $validator = new Step(['baseValue' => $baseValue, 'step' => $value]);
228
-                        else
229
-                            throw new \LogicException("The input type must be 'range'");
231
+                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) {
232
+                                                    $validator = new Step(['baseValue' => $baseValue, 'step' => $value]);
233
+                        } else {
234
+                                                    throw new \LogicException("The input type must be 'range'");
235
+                        }
230 236
 
231 237
                         break;
232 238
 
233 239
                     case 'data-validators':
234 240
 
235
-                        if (!is_array($value))
236
-                            throw new \InvalidArgumentException("Invalid type given. Array expected in 'data-validators' attribute.");
241
+                        if (!is_array($value)) {
242
+                                                    throw new \InvalidArgumentException("Invalid type given. Array expected in 'data-validators' attribute.");
243
+                        }
237 244
 
238 245
                         foreach ($value as $class => $params)
239 246
                         {
@@ -243,8 +250,9 @@  discard block
 block discarded – undo
243 250
                             {
244 251
                                 $className = "\Zend\I18n\Validator\\" . $class;
245 252
 
246
-                                if (!class_exists($className))
247
-                                    throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists");
253
+                                if (!class_exists($className)) {
254
+                                                                    throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists");
255
+                                }
248 256
                             }
249 257
 
250 258
                             $validator = new $className($params);
@@ -291,8 +299,9 @@  discard block
 block discarded – undo
291 299
             $v->setTranslator($this->translator);
292 300
             $notEmpty = $v->isValid($val);
293 301
 
294
-            if (!$required && !$notEmpty)
295
-                return null;
302
+            if (!$required && !$notEmpty) {
303
+                            return null;
304
+            }
296 305
 
297 306
             $valid = $validator->isValid($val);
298 307
             $this->setValid($valid);
@@ -304,8 +313,7 @@  discard block
 block discarded – undo
304 313
                     $this->error($label ."-~-". (count($this->getErrors()) + 1), $message);
305 314
                 }
306 315
             }
307
-        }
308
-        else
316
+        } else
309 317
         {
310 318
             foreach ($form_value as $val)
311 319
             {
@@ -330,8 +338,9 @@  discard block
 block discarded – undo
330 338
                 $errorLbl = explode("-~-", $key);
331 339
                 $label = array_shift($errorLbl);
332 340
 
333
-                if (!array_key_exists($label, $errors))
334
-                    $errors[$label] = [];
341
+                if (!array_key_exists($label, $errors)) {
342
+                                    $errors[$label] = [];
343
+                }
335 344
 
336 345
                 $errors[$label][] = $value;
337 346
             }
Please login to merge, or discard this patch.
src/Util/ArrayDimension.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@
 block discarded – undo
93 93
         {
94 94
             $new = array();
95 95
 
96
-            foreach($obj as $key => $val)
96
+            foreach ($obj as $key => $val)
97 97
             {
98 98
                 $new[$key] = self::objectToArray($val);
99 99
             }
Please login to merge, or discard this patch.
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
                     $again = true;
40 40
                     $new_config[$param . $glue . $key] = $value;
41 41
                 }
42
+            } else {
43
+                            $new_config[$param] = $configure;
42 44
             }
43
-            else
44
-                $new_config[$param] = $configure;
45 45
         }
46 46
 
47 47
         return (!$again) ? $new_config : self::toUnidimensional($new_config, $glue);
@@ -64,15 +64,17 @@  discard block
 block discarded – undo
64 64
 
65 65
         do
66 66
         {
67
-            if (array_key_exists($key, $haystack))
68
-                $haystack = $haystack[$key];
69
-            else
70
-                return $value;
67
+            if (array_key_exists($key, $haystack)) {
68
+                            $haystack = $haystack[$key];
69
+            } else {
70
+                            return $value;
71
+            }
71 72
 
72 73
             $key = count($needle) ? array_shift($needle) : NULL;
73 74
 
74
-            if (is_null($key))
75
-                return $haystack;
75
+            if (is_null($key)) {
76
+                            return $haystack;
77
+            }
76 78
 
77 79
         } while (!is_null($key));
78 80
     }
@@ -86,8 +88,9 @@  discard block
 block discarded – undo
86 88
      */
87 89
     public static function objectToArray($obj)
88 90
     {
89
-        if (is_object($obj))
90
-            $obj = (array) $obj;
91
+        if (is_object($obj)) {
92
+                    $obj = (array) $obj;
93
+        }
91 94
 
92 95
         if (is_array($obj))
93 96
         {
@@ -97,9 +100,9 @@  discard block
 block discarded – undo
97 100
             {
98 101
                 $new[$key] = self::objectToArray($val);
99 102
             }
103
+        } else {
104
+                    $new = $obj;
100 105
         }
101
-        else
102
-            $new = $obj;
103 106
 
104 107
         return $new;
105 108
     }
Please login to merge, or discard this patch.