Passed
Push — master ( 2d92e4...0d56ed )
by Darío
01:37
created
src/Validator/FormValidator.php 1 patch
Braces   +34 added lines, -26 removed lines patch added patch discarded remove patch
@@ -103,8 +103,9 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function getOption($key, $name)
105 105
     {
106
-        if (!array_key_exists($key, $this->options))
107
-            throw new \LogicException("The option '$key' does not exists");
106
+        if (!array_key_exists($key, $this->options)) {
107
+                    throw new \LogicException("The option '$key' does not exists");
108
+        }
108 109
 
109 110
         return array_key_exists($name, $this->options[$key]) ? $this->options[$key][$name] : null;
110 111
     }
@@ -158,8 +159,9 @@  discard block
 block discarded – undo
158 159
 
159 160
         foreach ($attribs as $key => $attributes)
160 161
         {
161
-            if (!array_key_exists($key, $attribs))
162
-                throw new \LogicException("The field '$key' does not exists!");
162
+            if (!array_key_exists($key, $attribs)) {
163
+                            throw new \LogicException("The field '$key' does not exists!");
164
+            }
163 165
 
164 166
             $label = (array_key_exists('label', array_keys($this->options))) ? $attributes["label"] : $key;
165 167
 
@@ -225,19 +227,21 @@  discard block
 block discarded – undo
225 227
 
226 228
                     case 'min':
227 229
 
228
-                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range']))
229
-                            $validator = new GreaterThan(['min' => $value, 'inclusive' => true]);
230
-                        else
231
-                            throw new \LogicException("The input type must be 'range' or 'number'");
230
+                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) {
231
+                                                    $validator = new GreaterThan(['min' => $value, 'inclusive' => true]);
232
+                        } else {
233
+                                                    throw new \LogicException("The input type must be 'range' or 'number'");
234
+                        }
232 235
 
233 236
                         break;
234 237
 
235 238
                     case 'max':
236 239
 
237
-                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range']))
238
-                            $validator = new LessThan(['max' => $value, 'inclusive' => true]);
239
-                        else
240
-                            throw new \LogicException("The input type must be 'range' or 'number'");
240
+                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) {
241
+                                                    $validator = new LessThan(['max' => $value, 'inclusive' => true]);
242
+                        } else {
243
+                                                    throw new \LogicException("The input type must be 'range' or 'number'");
244
+                        }
241 245
 
242 246
                         break;
243 247
 
@@ -245,10 +249,11 @@  discard block
 block discarded – undo
245 249
 
246 250
                         $baseValue = (array_key_exists('min', $all_attribs)) ? $all_attribs['min'] : 0;
247 251
 
248
-                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range']))
249
-                            $validator = new Step(['baseValue' => $baseValue, 'step' => $value]);
250
-                        else
251
-                            throw new \LogicException("The input type must be 'range'");
252
+                        if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) {
253
+                                                    $validator = new Step(['baseValue' => $baseValue, 'step' => $value]);
254
+                        } else {
255
+                                                    throw new \LogicException("The input type must be 'range'");
256
+                        }
252 257
 
253 258
                         break;
254 259
                 }
@@ -272,8 +277,9 @@  discard block
 block discarded – undo
272 277
                 $validator = new NotEmpty();
273 278
                 $attribute = $this->formHandler->getAttribute($key, "value");
274 279
 
275
-                if (is_null($attribute))
276
-                    throw new \LogicException("Missing attribute 'value' in '" . $key . "'.");
280
+                if (is_null($attribute)) {
281
+                                    throw new \LogicException("Missing attribute 'value' in '" . $key . "'.");
282
+                }
277 283
 
278 284
                 $value = $attribute->getValue();
279 285
 
@@ -287,8 +293,9 @@  discard block
 block discarded – undo
287 293
                         {
288 294
                             $className = "\Zend\I18n\Validator\\" . $class;
289 295
 
290
-                            if (!class_exists($className))
291
-                                throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists");
296
+                            if (!class_exists($className)) {
297
+                                                            throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists");
298
+                            }
292 299
                         }
293 300
 
294 301
                         $validator = new $className($params);
@@ -326,21 +333,22 @@  discard block
 block discarded – undo
326 333
             $v->setTranslator($this->translator);
327 334
             $notEmpty = $v->isValid($val);
328 335
 
329
-            if (!$required && !$notEmpty)
330
-                return null;
336
+            if (!$required && !$notEmpty) {
337
+                            return null;
338
+            }
331 339
 
332 340
             $valid = $validator->isValid($val);
333 341
             $this->setValid($valid);
334 342
 
335 343
             if (!$valid)
336 344
             {
337
-                if (!in_array($key, array_keys($this->messages)))
338
-                    $this->messages[$key] = array();
345
+                if (!in_array($key, array_keys($this->messages))) {
346
+                                    $this->messages[$key] = array();
347
+                }
339 348
 
340 349
                 $this->messages[$key] = array_merge($this->messages[$key], $validator->getMessages());
341 350
             }
342
-        }
343
-        else {
351
+        } else {
344 352
             foreach ($form_value as $val)
345 353
             {
346 354
                 $this->_validate($validator, $val, $key, $required);
Please login to merge, or discard this patch.
src/Dom/Element/AbstractElement.php 1 patch
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,8 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
         foreach ($attribs[$label] as $attrib)
110 110
         {
111
-            if ($attrib->getName() == $name)
112
-                return $attrib;
111
+            if ($attrib->getName() == $name) {
112
+                            return $attrib;
113
+            }
113 114
         }
114 115
     }
115 116
 
@@ -129,12 +130,12 @@  discard block
 block discarded – undo
129 130
         if (array_key_exists($label, $attribs))
130 131
         {
131 132
 
132
-            if (!array_key_exists($name, $attribs))
133
-                $this->attributes[$label][] = new Attribute($name, $value);
134
-            else
135
-                $this->getAttribute($label, $name)->setValue($value);
136
-        }
137
-        else {
133
+            if (!array_key_exists($name, $attribs)) {
134
+                            $this->attributes[$label][] = new Attribute($name, $value);
135
+            } else {
136
+                            $this->getAttribute($label, $name)->setValue($value);
137
+            }
138
+        } else {
138 139
             $this->attributes[$label][] = new Attribute($name, $value);
139 140
         }
140 141
     }
@@ -166,8 +167,9 @@  discard block
 block discarded – undo
166 167
      */
167 168
     public function __construct($options)
168 169
     {
169
-        if (!array_key_exists('endTag', $options))
170
-            $this->setEndTag(false);
170
+        if (!array_key_exists('endTag', $options)) {
171
+                    $this->setEndTag(false);
172
+        }
171 173
 
172 174
         foreach ($options as $key => $value)
173 175
         {
Please login to merge, or discard this patch.
src/Network/Rest/AbstractRest.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -127,8 +127,9 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function setWhiteList(array $whiteList)
129 129
     {
130
-        if (empty($whiteList))
131
-            throw new \RuntimeException("Empty whitelist!");
130
+        if (empty($whiteList)) {
131
+                    throw new \RuntimeException("Empty whitelist!");
132
+        }
132 133
 
133 134
         $this->whiteList = $whiteList;
134 135
     }
@@ -156,8 +157,9 @@  discard block
 block discarded – undo
156 157
     {
157 158
         foreach ($options as $option => $value)
158 159
         {
159
-            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option))
160
-            $this->{'set'.$option}($value);
160
+            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) {
161
+                        $this->{'set'.$option}($value);
162
+            }
161 163
         }
162 164
 
163 165
         # HTTP instance
Please login to merge, or discard this patch.
src/Network/Server.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,11 +64,13 @@
 block discarded – undo
64 64
      */
65 65
     public static function getClientIP()
66 66
     {
67
-        if (!empty($_SERVER['HTTP_CLIENT_IP']))
68
-            return $_SERVER['HTTP_CLIENT_IP'];
67
+        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
68
+                    return $_SERVER['HTTP_CLIENT_IP'];
69
+        }
69 70
 
70
-        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
71
-            return $_SERVER['HTTP_X_FORWARDED_FOR'];
71
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
72
+                    return $_SERVER['HTTP_X_FORWARDED_FOR'];
73
+        }
72 74
 
73 75
         return $_SERVER['REMOTE_ADDR'];
74 76
     }
Please login to merge, or discard this patch.
src/Util/ParamTrait.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,8 +70,9 @@
 block discarded – undo
70 70
     {
71 71
         $parameters = $this->getParams();
72 72
 
73
-        if (array_key_exists($param, $parameters))
74
-            return true;
73
+        if (array_key_exists($param, $parameters)) {
74
+                    return true;
75
+        }
75 76
 
76 77
         return false;
77 78
     }
Please login to merge, or discard this patch.
src/Exception/Storage.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,17 +76,20 @@
 block discarded – undo
76 76
             "object"  => serialize($exception)
77 77
         ];
78 78
 
79
-        if (!function_exists('mb_detect_encoding'))
80
-            throw new \RuntimeException("mbstring library is not installed!");
79
+        if (!function_exists('mb_detect_encoding')) {
80
+                    throw new \RuntimeException("mbstring library is not installed!");
81
+        }
81 82
 
82 83
         /*
83 84
          * Encodes to UTF8 all messages. It ensures JSON encoding.
84 85
          */
85
-        if (!mb_detect_encoding($data[$id]["message"], 'UTF-8', true))
86
-            $data[$id]["message"] = utf8_encode($data[$id]["message"]);
86
+        if (!mb_detect_encoding($data[$id]["message"], 'UTF-8', true)) {
87
+                    $data[$id]["message"] = utf8_encode($data[$id]["message"]);
88
+        }
87 89
 
88
-        if (!mb_detect_encoding($data[$id]["object"], 'UTF-8', true))
89
-            $data[$id]["object"] = utf8_decode($data[$id]["object"]);
90
+        if (!mb_detect_encoding($data[$id]["object"], 'UTF-8', true)) {
91
+                    $data[$id]["object"] = utf8_decode($data[$id]["object"]);
92
+        }
90 93
 
91 94
         if (($encoded_data = json_encode($data)) === false)
92 95
         {
Please login to merge, or discard this patch.
src/Mvc/Router.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -145,8 +145,9 @@  discard block
 block discarded – undo
145 145
         $module = (is_null($this->identifiers["module"]) || empty($this->identifiers["module"]))
146 146
                     ? $this->routes["defaults"]["module"] : $this->identifiers["module"];
147 147
 
148
-        if (!array_key_exists($module, $this->routes))
149
-            throw new Exception\ModuleNotFoundException("The key '$module' does not exists in routes!");
148
+        if (!array_key_exists($module, $this->routes)) {
149
+                    throw new Exception\ModuleNotFoundException("The key '$module' does not exists in routes!");
150
+        }
150 151
 
151 152
         $controller = (is_null($this->identifiers["controller"]) || empty($this->identifiers["controller"]))
152 153
                     ? $this->routes[$module]["controller"] : $this->identifiers["controller"];
@@ -156,10 +157,11 @@  discard block
 block discarded – undo
156 157
 
157 158
         $fqn_controller = '\\' . $module . "\Controller\\" . $controller;
158 159
 
159
-        if (class_exists($fqn_controller))
160
-            $this->controller = new $fqn_controller($module, $view, $this->basePath);
161
-        else
162
-            throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!");
160
+        if (class_exists($fqn_controller)) {
161
+                    $this->controller = new $fqn_controller($module, $view, $this->basePath);
162
+        } else {
163
+                    throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!");
164
+        }
163 165
     }
164 166
 
165 167
     /**
@@ -176,8 +178,9 @@  discard block
 block discarded – undo
176 178
         $key = array_keys($route);
177 179
         $key = array_shift($key);
178 180
 
179
-        if (array_key_exists($key, $this->routes))
180
-            throw new \LogicException("The key '$key' was already defined as route");
181
+        if (array_key_exists($key, $this->routes)) {
182
+                    throw new \LogicException("The key '$key' was already defined as route");
183
+        }
181 184
 
182 185
         $this->routes = array_merge($this->routes, $route);
183 186
     }
Please login to merge, or discard this patch.
src/Mvc/AbstractionModule.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,8 @@
 block discarded – undo
80 80
 
81 81
         $class = "module/" . $module . "/source/" . implode("/", $nm) . ".php";
82 82
 
83
-        if (file_exists($class))
84
-            include $class;
83
+        if (file_exists($class)) {
84
+                    include $class;
85
+        }
85 86
     }
86 87
 }
87 88
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/Driver/DriverAdapter.php 1 patch
Braces   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -85,13 +85,14 @@  discard block
 block discarded – undo
85 85
             "Sqlsrv" => "Drone\Db\Driver\SQLServer",
86 86
         ];
87 87
 
88
-        if (gettype($connection_identifier) == 'array')
89
-            $connection_array = $connection_identifier;
90
-        else
88
+        if (gettype($connection_identifier) == 'array') {
89
+                    $connection_array = $connection_identifier;
90
+        } else
91 91
         {
92 92
             # Take connection parameters from configuration file
93
-            if (!file_exists("config/database.config.php"))
94
-                throw new \RuntimeException("config/data.base.config.php is missing!");
93
+            if (!file_exists("config/database.config.php")) {
94
+                            throw new \RuntimeException("config/data.base.config.php is missing!");
95
+            }
95 96
 
96 97
             $dbsettings = include("config/database.config.php");
97 98
             $connection_array = $dbsettings[$connection_identifier];
@@ -106,8 +107,8 @@  discard block
 block discarded – undo
106 107
 
107 108
             $this->driverName = $drv;
108 109
             $this->db = new $driver[$drv]($connection_array);
110
+        } else {
111
+                    throw new \RuntimeException("The Database driver does not exists");
109 112
         }
110
-        else
111
-            throw new \RuntimeException("The Database driver does not exists");
112 113
     }
113 114
 }
114 115
\ No newline at end of file
Please login to merge, or discard this patch.