Passed
Push — master ( b0d82b...8f50d0 )
by Darío
01:40
created
test/Util/DateTimeTest.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,13 +39,11 @@
 block discarded – undo
39 39
         try
40 40
         {
41 41
             $this->assertEquals('June', Dt::getMonth(13));
42
-        }
43
-        catch (\Exception $e)
42
+        } catch (\Exception $e)
44 43
         {
45 44
             $errorObject = ($e instanceof MonthOutOfRange);
46 45
             $message = $e->getMessage();
47
-        }
48
-        finally
46
+        } finally
49 47
         {
50 48
             $this->assertTrue($errorObject, $message);
51 49
         }
Please login to merge, or discard this patch.
test/Db/TableGateway/TableGatewayTest.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -78,13 +78,11 @@  discard block
 block discarded – undo
78 78
         {
79 79
             $entity = new MyEntity();
80 80
             $gateway = new TableGateway($entity, ["default" => $options]);
81
-        }
82
-        catch (\Exception $e)
81
+        } catch (\Exception $e)
83 82
         {
84 83
             $errorObject = ($e instanceof \RuntimeException);
85 84
             $message = $e->getMessage();
86
-        }
87
-        finally
85
+        } finally
88 86
         {
89 87
             $this->assertTrue($errorObject, $message);
90 88
         }
@@ -110,13 +108,11 @@  discard block
 block discarded – undo
110 108
         try
111 109
         {
112 110
             $gateway->getDb()->connect();
113
-        }
114
-        catch (\Exception $e)
111
+        } catch (\Exception $e)
115 112
         {
116 113
             $errorObject = ($e instanceof ConnectionException);
117 114
             $message = $e->getMessage();
118
-        }
119
-        finally
115
+        } finally
120 116
         {
121 117
             $this->assertTrue($errorObject, $message);
122 118
             $this->assertNotTrue($gateway->getDb()->isConnected());
@@ -145,13 +141,11 @@  discard block
 block discarded – undo
145 141
         try
146 142
         {
147 143
             AbstractTableGateway::getDriver('other3');
148
-        }
149
-        catch (\Exception $e)
144
+        } catch (\Exception $e)
150 145
         {
151 146
             $errorObject = ($e instanceof \RuntimeException);
152 147
             $message = $e->getMessage();
153
-        }
154
-        finally
148
+        } finally
155 149
         {
156 150
             $this->assertTrue($errorObject, $message);
157 151
         }
@@ -250,13 +244,11 @@  discard block
 block discarded – undo
250 244
         try
251 245
         {
252 246
             $gateway->wrongDML();
253
-        }
254
-        catch (\Exception $e)
247
+        } catch (\Exception $e)
255 248
         {
256 249
             $errorObject = ($e instanceof InvalidQueryException);
257 250
             $message = $e->getMessage();
258
-        }
259
-        finally
251
+        } finally
260 252
         {
261 253
             $this->assertTrue($errorObject, $message);
262 254
         }
Please login to merge, or discard this patch.
src/Db/TableGateway/AbstractTableGateway.php 1 patch
Braces   +18 added lines, -15 removed lines patch added patch discarded remove patch
@@ -87,24 +87,25 @@  discard block
 block discarded – undo
87 87
         {
88 88
             $this->currentConnection = $connection;
89 89
             $this->getDriver($connection);
90
-        }
91
-        else if (is_array($connection))
90
+        } else if (is_array($connection))
92 91
         {
93 92
             $identifier = key($connection);
94 93
             $connection_options = $connection[$identifier];
95 94
 
96 95
             $this->currentConnection = $identifier;
97 96
 
98
-            if (!array_key_exists('driver', $connection_options))
99
-                throw new \RuntimeException("The database driver key has not been declared");
100
-
101
-            if (!isset(self::$drivers[$identifier]))
102
-                self::$drivers[$identifier] = DriverFactory::create($connection_options);
103
-            else
104
-                throw new \RuntimeException("The database connection already exists");
97
+            if (!array_key_exists('driver', $connection_options)) {
98
+                            throw new \RuntimeException("The database driver key has not been declared");
99
+            }
100
+
101
+            if (!isset(self::$drivers[$identifier])) {
102
+                            self::$drivers[$identifier] = DriverFactory::create($connection_options);
103
+            } else {
104
+                            throw new \RuntimeException("The database connection already exists");
105
+            }
106
+        } else {
107
+                    throw new \InvalidArgumentException("Invalid type given. Array or string expected");
105 108
         }
106
-        else
107
-            throw new \InvalidArgumentException("Invalid type given. Array or string expected");
108 109
     }
109 110
 
110 111
     /**
@@ -118,8 +119,9 @@  discard block
 block discarded – undo
118 119
      */
119 120
     public static function getDriver($identifier)
120 121
     {
121
-        if (!array_key_exists($identifier, self::$drivers))
122
-            throw new \RuntimeException("The database connection does not exists");
122
+        if (!array_key_exists($identifier, self::$drivers)) {
123
+                    throw new \RuntimeException("The database connection does not exists");
124
+        }
123 125
 
124 126
         return self::$drivers[$identifier];
125 127
     }
@@ -135,8 +137,9 @@  discard block
 block discarded – undo
135 137
      */
136 138
     public static function hasDriver($identifier)
137 139
     {
138
-        if (!array_key_exists($identifier, self::$drivers))
139
-            return false;
140
+        if (!array_key_exists($identifier, self::$drivers)) {
141
+                    return false;
142
+        }
140 143
 
141 144
         return true;
142 145
     }
Please login to merge, or discard this patch.
src/Db/Driver/DriverFactory.php 1 patch
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,14 +34,16 @@
 block discarded – undo
34 34
             "Sqlsrv" => "Drone\Db\Driver\SQLServer",
35 35
         ];
36 36
 
37
-        if (!array_key_exists('driver', $connection_options))
38
-            throw new \RuntimeException("The database driver key has not been declared");
37
+        if (!array_key_exists('driver', $connection_options)) {
38
+                    throw new \RuntimeException("The database driver key has not been declared");
39
+        }
39 40
 
40 41
         $drv = $connection_options["driver"];
41 42
 
42
-        if (array_key_exists($drv, $drivers))
43
-            return new $drivers[$drv]($connection_options);
44
-        else
45
-            throw new \RuntimeException("The database driver does not exists");
43
+        if (array_key_exists($drv, $drivers)) {
44
+                    return new $drivers[$drv]($connection_options);
45
+        } else {
46
+                    throw new \RuntimeException("The database driver does not exists");
47
+        }
46 48
     }
47 49
 }
48 50
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/TableGateway/TableGateway.php 1 patch
Braces   +50 added lines, -49 removed lines patch added patch discarded remove patch
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
             {
79 79
                 $k++;
80 80
 
81
-                if (is_null($value))
82
-                    $parsed_where[] = "$key IS NULL";
83
-                elseif ($value instanceof SQLFunction)
84
-                    $parsed_where[] = "$key = " . $value->getStatement();
85
-                elseif (is_array($value))
81
+                if (is_null($value)) {
82
+                                    $parsed_where[] = "$key IS NULL";
83
+                } elseif ($value instanceof SQLFunction) {
84
+                                    $parsed_where[] = "$key = " . $value->getStatement();
85
+                } elseif (is_array($value))
86 86
                 {
87 87
                     $parsed_in = [];
88 88
 
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
                     }
106 106
 
107 107
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
108
-                }
109
-                else
108
+                } else
110 109
                 {
111 110
                     switch ($driver)
112 111
                     {
@@ -124,9 +123,9 @@  discard block
 block discarded – undo
124 123
             }
125 124
 
126 125
             $where = "WHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
126
+        } else {
127
+                    $where = "";
127 128
         }
128
-        else
129
-            $where = "";
130 129
 
131 130
         $table = $this->entity->getTableName();
132 131
 
@@ -135,10 +134,11 @@  discard block
 block discarded – undo
135 134
         $this->lastQuery = $sql;
136 135
         $this->lastValues = $bind_values;
137 136
 
138
-        if (count($bind_values))
139
-            $this->getDb()->execute($sql, $bind_values);
140
-        else
141
-            $this->getDb()->execute($sql);
137
+        if (count($bind_values)) {
138
+                    $this->getDb()->execute($sql, $bind_values);
139
+        } else {
140
+                    $this->getDb()->execute($sql);
141
+        }
142 142
 
143 143
         return $this->getDb()->getArrayResult();
144 144
     }
@@ -155,8 +155,9 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function insert(Array $data)
157 157
     {
158
-        if (!count($data))
159
-            throw new \LogicException("Missing values for INSERT statement!");
158
+        if (!count($data)) {
159
+                    throw new \LogicException("Missing values for INSERT statement!");
160
+        }
160 161
 
161 162
         $bind_values = [];
162 163
 
@@ -179,11 +180,11 @@  discard block
 block discarded – undo
179 180
                 continue;
180 181
             }
181 182
 
182
-            if (is_null($value))
183
-                $value = "NULL";
184
-            elseif ($value instanceof SQLFunction)
185
-                $value = $value->getStatement();
186
-            else {
183
+            if (is_null($value)) {
184
+                            $value = "NULL";
185
+            } elseif ($value instanceof SQLFunction) {
186
+                            $value = $value->getStatement();
187
+            } else {
187 188
 
188 189
                 switch ($driver)
189 190
                 {
@@ -236,11 +237,13 @@  discard block
 block discarded – undo
236 237
     {
237 238
         $parsed_set = [];
238 239
 
239
-        if (!count($set))
240
-            throw new \LogicException("You cannot update rows without SET clause");
240
+        if (!count($set)) {
241
+                    throw new \LogicException("You cannot update rows without SET clause");
242
+        }
241 243
 
242
-        if (!count($where))
243
-            throw new SecurityException("You cannot update rows without WHERE clause!");
244
+        if (!count($where)) {
245
+                    throw new SecurityException("You cannot update rows without WHERE clause!");
246
+        }
244 247
 
245 248
         $bind_values = [];
246 249
 
@@ -252,11 +255,11 @@  discard block
 block discarded – undo
252 255
         {
253 256
             $k++;
254 257
 
255
-            if (is_null($value))
256
-                $parsed_set[] = "$key = NULL";
257
-            elseif ($value instanceof SQLFunction)
258
-                $parsed_set[] = "$key = " . $value->getStatement();
259
-            elseif (is_array($value))
258
+            if (is_null($value)) {
259
+                            $parsed_set[] = "$key = NULL";
260
+            } elseif ($value instanceof SQLFunction) {
261
+                            $parsed_set[] = "$key = " . $value->getStatement();
262
+            } elseif (is_array($value))
260 263
             {
261 264
                 $parsed_in = [];
262 265
 
@@ -267,8 +270,9 @@  discard block
 block discarded – undo
267 270
                         case 'Oci8':
268 271
 
269 272
                             # [POSSIBLE BUG] - To Future revision (What about non-string values ?)
270
-                            if (is_string($in_value))
271
-                                $parsed_in[] = ":$k";
273
+                            if (is_string($in_value)) {
274
+                                                            $parsed_in[] = ":$k";
275
+                            }
272 276
 
273 277
                             $bind_values[":$k"] = $in_value;
274 278
                             break;
@@ -283,8 +287,7 @@  discard block
 block discarded – undo
283 287
                 }
284 288
 
285 289
                 $parsed_set[] = "$key IN (" . implode(", ", $parsed_in) . ")";
286
-            }
287
-            else
290
+            } else
288 291
             {
289 292
                 switch ($driver)
290 293
                 {
@@ -309,11 +312,11 @@  discard block
 block discarded – undo
309 312
         {
310 313
             $k++;
311 314
 
312
-            if (is_null($value))
313
-                $parsed_where[] = "$key IS NULL";
314
-            elseif ($value instanceof SQLFunction)
315
-                $parsed_where[] = "$key = " . $value->getStatement();
316
-            elseif (is_array($value))
315
+            if (is_null($value)) {
316
+                            $parsed_where[] = "$key IS NULL";
317
+            } elseif ($value instanceof SQLFunction) {
318
+                            $parsed_where[] = "$key = " . $value->getStatement();
319
+            } elseif (is_array($value))
317 320
             {
318 321
                 $parsed_in = [];
319 322
 
@@ -336,8 +339,7 @@  discard block
 block discarded – undo
336 339
                 }
337 340
 
338 341
                 $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
339
-            }
340
-            else
342
+            } else
341 343
             {
342 344
                 switch ($driver)
343 345
                 {
@@ -392,11 +394,11 @@  discard block
 block discarded – undo
392 394
             {
393 395
                 $k++;
394 396
 
395
-                if (is_null($value))
396
-                    $parsed_where[] = "$key IS NULL";
397
-                elseif ($value instanceof SQLFunction)
398
-                    $parsed_where[] = "$key = " . $value->getStatement();
399
-                elseif (is_array($value))
397
+                if (is_null($value)) {
398
+                                    $parsed_where[] = "$key IS NULL";
399
+                } elseif ($value instanceof SQLFunction) {
400
+                                    $parsed_where[] = "$key = " . $value->getStatement();
401
+                } elseif (is_array($value))
400 402
                 {
401 403
                     $parsed_in = [];
402 404
 
@@ -419,8 +421,7 @@  discard block
 block discarded – undo
419 421
                     }
420 422
 
421 423
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
422
-                }
423
-                else
424
+                } else
424 425
                 {
425 426
                     switch ($driver)
426 427
                     {
@@ -438,9 +439,9 @@  discard block
 block discarded – undo
438 439
             }
439 440
 
440 441
             $where = "\r\nWHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
442
+        } else {
443
+                    throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
441 444
         }
442
-        else
443
-            throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
444 445
 
445 446
         $table = $this->entity->getTableName();
446 447
 
Please login to merge, or discard this patch.
src/Dom/Element/ElementFactory.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@
 block discarded – undo
38 38
         {
39 39
             foreach ($attributes as $name => $value)
40 40
             {
41
-                if (!is_string($name))
42
-                    throw new \InvalidArgumentException("Attribute only accepts strings as names");
41
+                if (!is_string($name)) {
42
+                                    throw new \InvalidArgumentException("Attribute only accepts strings as names");
43
+                }
43 44
 
44 45
                 $instance->setAttribute(new Attribute($name, $value));
45 46
             }
Please login to merge, or discard this patch.
src/Dom/Element/Form.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,11 +48,13 @@
 block discarded – undo
48 48
         {
49 49
             $child = $this->getChild($label);
50 50
 
51
-            if (is_null($child))
52
-                throw new Exception\ChildNotFoundException("The child '$label' does not exists inside the form element");
51
+            if (is_null($child)) {
52
+                            throw new Exception\ChildNotFoundException("The child '$label' does not exists inside the form element");
53
+            }
53 54
 
54
-            if (!$child->isFormControl())
55
-                throw new Exception\NotFormControlException("The child '$label' is not a form control");
55
+            if (!$child->isFormControl()) {
56
+                            throw new Exception\NotFormControlException("The child '$label' is not a form control");
57
+            }
56 58
 
57 59
             $child->setAttribute(new Attribute("value", $value));
58 60
         }
Please login to merge, or discard this patch.
src/Dom/Element/AbstractElement.php 1 patch
Braces   +29 added lines, -22 removed lines patch added patch discarded remove patch
@@ -110,8 +110,9 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function hasChild($label)
112 112
     {
113
-        if (array_key_exists($label, $this->children))
114
-            return true;
113
+        if (array_key_exists($label, $this->children)) {
114
+                    return true;
115
+        }
115 116
 
116 117
         return false;
117 118
     }
@@ -125,8 +126,9 @@  discard block
 block discarded – undo
125 126
      */
126 127
     public function getChild($label)
127 128
     {
128
-        if (array_key_exists($label, $this->children))
129
-            return $this->children[$label];
129
+        if (array_key_exists($label, $this->children)) {
130
+                    return $this->children[$label];
131
+        }
130 132
 
131 133
         return null;
132 134
     }
@@ -155,10 +157,11 @@  discard block
 block discarded – undo
155 157
      */
156 158
     public function removeChild($label)
157 159
     {
158
-        if (array_key_exists($label, $this->children))
159
-            unset($this->children[$label]);
160
-        else
161
-            throw new Exception\ChildNotFoundException("The child to remove does not exists");
160
+        if (array_key_exists($label, $this->children)) {
161
+                    unset($this->children[$label]);
162
+        } else {
163
+                    throw new Exception\ChildNotFoundException("The child to remove does not exists");
164
+        }
162 165
     }
163 166
 
164 167
     /**
@@ -174,8 +177,9 @@  discard block
 block discarded – undo
174 177
         {
175 178
             foreach ($this->attributes as $attrib)
176 179
             {
177
-                if ($attrib->getName() == $name)
178
-                    return true;
180
+                if ($attrib->getName() == $name) {
181
+                                    return true;
182
+                }
179 183
             }
180 184
         }
181 185
 
@@ -195,8 +199,9 @@  discard block
 block discarded – undo
195 199
         {
196 200
             foreach ($this->attributes as $attrib)
197 201
             {
198
-                if ($attrib->getName() == $name)
199
-                    return $attrib;
202
+                if ($attrib->getName() == $name) {
203
+                                    return $attrib;
204
+                }
200 205
             }
201 206
         }
202 207
 
@@ -218,12 +223,13 @@  discard block
 block discarded – undo
218 223
         {
219 224
             foreach ($this->attributes as $key => $_attrib)
220 225
             {
221
-                if ($_attrib->getName() == $attrib->getName())
222
-                    $this->attributes[$key] = $attribute;
226
+                if ($_attrib->getName() == $attrib->getName()) {
227
+                                    $this->attributes[$key] = $attribute;
228
+                }
223 229
             }
230
+        } else {
231
+                    $this->attributes[] = $attribute;
224 232
         }
225
-        else
226
-            $this->attributes[] = $attribute;
227 233
     }
228 234
 
229 235
     /**
@@ -241,8 +247,9 @@  discard block
 block discarded – undo
241 247
         {
242 248
             foreach ($this->attributes as $key => $attrib)
243 249
             {
244
-                if ($attrib->getName() == $name)
245
-                    unset($this->attributes[$key]);
250
+                if ($attrib->getName() == $name) {
251
+                                    unset($this->attributes[$key]);
252
+                }
246 253
             }
247 254
         }
248 255
 
@@ -260,8 +267,7 @@  discard block
 block discarded – undo
260 267
         {
261 268
             $this->startTag = "<" .strtolower(static::NODE_NAME). ">";
262 269
             $this->endTag   = "</" .strtolower(static::NODE_NAME). ">";
263
-        }
264
-        else
270
+        } else
265 271
         {
266 272
             $this->startTag = "<" .strtolower(static::NODE_NAME);
267 273
             $this->endTag   = "/>";
@@ -275,8 +281,9 @@  discard block
 block discarded – undo
275 281
      */
276 282
     public function isFormControl()
277 283
     {
278
-        if (in_array(static::NODE_NAME, ['INPUT']))
279
-            return true;
284
+        if (in_array(static::NODE_NAME, ['INPUT'])) {
285
+                    return true;
286
+        }
280 287
 
281 288
         return false;
282 289
     }
Please login to merge, or discard this patch.
src/Error/ErrorTrait.php 1 patch
Braces   +17 added lines, -13 removed lines patch added patch discarded remove patch
@@ -92,29 +92,32 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function _error($code, $message = null)
94 94
     {
95
-        if (!is_null($code) && !is_integer($code) && !is_string($code))
96
-            throw new \InvalidArgumentException("Invalid type given. Integer or string expected");
95
+        if (!is_null($code) && !is_integer($code) && !is_string($code)) {
96
+                    throw new \InvalidArgumentException("Invalid type given. Integer or string expected");
97
+        }
97 98
 
98
-        if (is_null($code))
99
-            $code = preg_replace('/=|\/|\+/', "", base64_encode($message));
100
-        else
99
+        if (is_null($code)) {
100
+                    $code = preg_replace('/=|\/|\+/', "", base64_encode($message));
101
+        } else
101 102
         {
102
-            if (!array_key_exists($code, $this->standardErrors) && empty($message))
103
-                /*
103
+            if (!array_key_exists($code, $this->standardErrors) && empty($message)) {
104
+                            /*
104 105
                  * Non-standard errors must have a message to describe the error, make sure
105 106
                  * you execute the error() method with a message as the second parameter.
106 107
                  */
107 108
                 throw new \LogicException('The message does not be empty in non-standard errors!');
109
+            }
108 110
         }
109 111
 
110
-        if (!array_key_exists($code, $this->errors))
111
-            $this->errors[$code] = (array_key_exists($code, $this->standardErrors))
112
+        if (!array_key_exists($code, $this->errors)) {
113
+                    $this->errors[$code] = (array_key_exists($code, $this->standardErrors))
112 114
                 ?
113 115
                     is_null($message)
114 116
                         ? preg_replace('/\s\'%[a-zA-Z]*%\'/', $message, $this->standardErrors[$code])
115 117
                         # if $message is not null it will replace the %file% wildcard
116 118
                         : preg_replace('/%[a-zA-Z]*%/', $message, $this->standardErrors[$code])
117 119
                 : $message;
120
+        }
118 121
     }
119 122
 
120 123
     function __call($method, $arguments)
@@ -124,10 +127,11 @@  discard block
 block discarded – undo
124 127
             switch (count($arguments))
125 128
             {
126 129
                 case 1:
127
-                    if (is_integer($arguments[0]))
128
-                        return call_user_func([$this, '_error'], array_shift($arguments));
129
-                    else
130
-                        return call_user_func([$this, '_error'], null, array_shift($arguments));
130
+                    if (is_integer($arguments[0])) {
131
+                                            return call_user_func([$this, '_error'], array_shift($arguments));
132
+                    } else {
133
+                                            return call_user_func([$this, '_error'], null, array_shift($arguments));
134
+                    }
131 135
                     break;
132 136
                 case 2:
133 137
                     return call_user_func([$this, '_error'], $arguments[0], $arguments[1]);
Please login to merge, or discard this patch.