Passed
Push — master ( b79870...34b184 )
by Darío
02:37
created
src/Mvc/AbstractionController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
         if ($_SERVER['REQUEST_METHOD'] != 'JSON')
169 169
             throw new \LogicException("Request method is not JSON");
170 170
 
171
-        $input =  file_get_contents('php://input');
171
+        $input = file_get_contents('php://input');
172 172
         $array = explode("&", $input);
173 173
 
174 174
         $result = array();
Please login to merge, or discard this patch.
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -150,8 +150,9 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function getPost()
152 152
     {
153
-        if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST))
154
-            $_POST = json_decode(file_get_contents('php://input'), true);
153
+        if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST)) {
154
+                    $_POST = json_decode(file_get_contents('php://input'), true);
155
+        }
155 156
 
156 157
         return (array) $_POST;
157 158
     }
@@ -165,8 +166,9 @@  discard block
 block discarded – undo
165 166
      */
166 167
     public function getJson()
167 168
     {
168
-        if ($_SERVER['REQUEST_METHOD'] != 'JSON')
169
-            throw new \LogicException("Request method is not JSON");
169
+        if ($_SERVER['REQUEST_METHOD'] != 'JSON') {
170
+                    throw new \LogicException("Request method is not JSON");
171
+        }
170 172
 
171 173
         $input =  file_get_contents('php://input');
172 174
         $array = explode("&", $input);
@@ -254,8 +256,9 @@  discard block
 block discarded – undo
254 256
         $this->module = new $fqn($module, $this);
255 257
 
256 258
         # detects method change inside Module.php
257
-        if (!is_null($this->getMethod()))
258
-            $method = $this->getMethod();
259
+        if (!is_null($this->getMethod())) {
260
+                    $method = $this->getMethod();
261
+        }
259 262
 
260 263
         if (!is_null($method) && $this->initExecution)
261 264
         {
@@ -265,8 +268,9 @@  discard block
 block discarded – undo
265 268
 
266 269
                 $reflection = new \ReflectionMethod($this, $method);
267 270
 
268
-                if (!$reflection->isPublic())
269
-                    throw new Exception\PageNotFoundException("The method '$method' is not public in the control class '$class'");
271
+                if (!$reflection->isPublic()) {
272
+                                    throw new Exception\PageNotFoundException("The method '$method' is not public in the control class '$class'");
273
+                }
270 274
 
271 275
                 $this->method = $method;
272 276
 
@@ -282,8 +286,7 @@  discard block
 block discarded – undo
282 286
                     $layoutManager = new Layout($layout_params);
283 287
                     $layoutManager->fromController($this);
284 288
                 }
285
-            }
286
-            else {
289
+            } else {
287 290
                 $class = __CLASS__;
288 291
                 throw new Exception\PageNotFoundException("The method '$method' doesn't exists in the control class '$class'");
289 292
             }
@@ -308,8 +311,9 @@  discard block
 block discarded – undo
308 311
     public function isXmlHttpRequest()
309 312
     {
310 313
         # non standard (HTTP_X_REQUESTED_WITH is not a part of PHP)
311
-        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']))
312
-            return true;
314
+        if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
315
+                    return true;
316
+        }
313 317
         return false;
314 318
     }
315 319
 
@@ -320,8 +324,9 @@  discard block
 block discarded – undo
320 324
      */
321 325
     public function isPost()
322 326
     {
323
-        if ($_SERVER["REQUEST_METHOD"] == "POST")
324
-            return true;
327
+        if ($_SERVER["REQUEST_METHOD"] == "POST") {
328
+                    return true;
329
+        }
325 330
         return false;
326 331
     }
327 332
 
@@ -332,8 +337,9 @@  discard block
 block discarded – undo
332 337
      */
333 338
     public function isGet()
334 339
     {
335
-        if ($_SERVER["REQUEST_METHOD"] == "GET")
336
-            return true;
340
+        if ($_SERVER["REQUEST_METHOD"] == "GET") {
341
+                    return true;
342
+        }
337 343
         return false;
338 344
     }
339 345
 
@@ -357,19 +363,21 @@  discard block
 block discarded – undo
357 363
             $i = 1;
358 364
             foreach ($params as $item)
359 365
             {
360
-                if ($i % 2 != 0)
361
-                    $vars[] = $item;
362
-                else
363
-                    $values[] = $item;
366
+                if ($i % 2 != 0) {
367
+                                    $vars[] = $item;
368
+                } else {
369
+                                    $values[] = $item;
370
+                }
364 371
                 $i++;
365 372
             }
366 373
 
367 374
             for ($i = 0; $i < count($vars); $i++)
368 375
             {
369
-                if (array_key_exists($i, $values))
370
-                    $_GET[$vars[$i]] = $values[$i];
371
-                else
372
-                    $_GET[$vars[$i]] = '';
376
+                if (array_key_exists($i, $values)) {
377
+                                    $_GET[$vars[$i]] = $values[$i];
378
+                } else {
379
+                                    $_GET[$vars[$i]] = '';
380
+                }
373 381
             }
374 382
 
375 383
             unset($_GET["params"]);
Please login to merge, or discard this patch.
src/Mvc/Layout.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     {
165 165
         foreach ($params as $param => $value)
166 166
         {
167
-            if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param))
168
-                $this->{'set'.$param}($value);
167
+            if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set' . $param))
168
+                $this->{'set' . $param}($value);
169 169
         }
170 170
     }
171 171
 
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 
186 186
         if ($controller->getShowView())
187 187
         {
188
-            $view = 'module/'      . $controller->getModule()->getModuleName() .
189
-                    '/source/view/'. basename(str_replace('\\','/',get_class($controller))) .
190
-                    '/'            . $controller->getMethod() . '.phtml';
188
+            $view = 'module/' . $controller->getModule()->getModuleName() .
189
+                    '/source/view/' . basename(str_replace('\\', '/', get_class($controller))) .
190
+                    '/' . $controller->getMethod() . '.phtml';
191 191
 
192 192
             $this->view = $view;
193 193
         }
Please login to merge, or discard this patch.
Braces   +22 added lines, -16 removed lines patch added patch discarded remove patch
@@ -133,8 +133,9 @@  discard block
 block discarded – undo
133 133
     {
134 134
         $config = $module->getConfig();
135 135
 
136
-        if (!array_key_exists($view, $config["view_manager"]["view_map"]) || !file_exists($config["view_manager"]["view_map"][$view]))
137
-            throw new Exception\ViewNotFoundException("The 'view' template " . $view . " does not exists");
136
+        if (!array_key_exists($view, $config["view_manager"]["view_map"]) || !file_exists($config["view_manager"]["view_map"][$view])) {
137
+                    throw new Exception\ViewNotFoundException("The 'view' template " . $view . " does not exists");
138
+        }
138 139
 
139 140
         $this->view = $config["view_manager"]["view_map"][$view];
140 141
     }
@@ -164,8 +165,9 @@  discard block
 block discarded – undo
164 165
     {
165 166
         foreach ($params as $param => $value)
166 167
         {
167
-            if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param))
168
-                $this->{'set'.$param}($value);
168
+            if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param)) {
169
+                            $this->{'set'.$param}($value);
170
+            }
169 171
         }
170 172
     }
171 173
 
@@ -194,23 +196,26 @@  discard block
 block discarded – undo
194 196
 
195 197
         if ($controller->getTerminal())
196 198
         {
197
-            if (file_exists($view))
198
-                include $view;
199
-        }
200
-        else
199
+            if (file_exists($view)) {
200
+                            include $view;
201
+            }
202
+        } else
201 203
         {
202
-            if (!is_null($this->view) && !file_exists($this->view))
203
-                throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists");
204
+            if (!is_null($this->view) && !file_exists($this->view)) {
205
+                            throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists");
206
+            }
204 207
 
205 208
             $config = $controller->getModule()->getConfig();
206 209
 
207
-            if (!array_key_exists($controller->getLayout(), $config["view_manager"]["template_map"]))
208
-                throw new Exception\PageFoundException("The 'template' " . $template . " was not defined in module.config.php");
210
+            if (!array_key_exists($controller->getLayout(), $config["view_manager"]["template_map"])) {
211
+                            throw new Exception\PageFoundException("The 'template' " . $template . " was not defined in module.config.php");
212
+            }
209 213
 
210 214
             $template = $config["view_manager"]["template_map"][$controller->getLayout()];
211 215
 
212
-            if (!file_exists($template))
213
-                throw new Exception\PageFoundException("The 'template' " . $template . " does not exists");
216
+            if (!file_exists($template)) {
217
+                            throw new Exception\PageFoundException("The 'template' " . $template . " does not exists");
218
+            }
214 219
 
215 220
             include $template;
216 221
         }
@@ -237,8 +242,9 @@  discard block
 block discarded – undo
237 242
      */
238 243
     public function content()
239 244
     {
240
-        if (!file_exists($this->view))
241
-            throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists");
245
+        if (!file_exists($this->view)) {
246
+                    throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists");
247
+        }
242 248
 
243 249
         include $this->view;
244 250
     }
Please login to merge, or discard this patch.
src/Db/Entity.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -109,11 +109,12 @@
 block discarded – undo
109 109
             {
110 110
                 $this->$prop = $value;
111 111
 
112
-                if (!in_array($prop, $this->changedFields))
113
-                    $this->changedFields[] = $prop;
112
+                if (!in_array($prop, $this->changedFields)) {
113
+                                    $this->changedFields[] = $prop;
114
+                }
115
+            } else {
116
+                            throw new \LogicException("The property '$prop' does not exists in the class '$class'");
114 117
             }
115
-            else
116
-                throw new \LogicException("The property '$prop' does not exists in the class '$class'");
117 118
         }
118 119
     }
119 120
 
Please login to merge, or discard this patch.
src/Db/Driver/AbstractDriver.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -298,8 +298,8 @@
 block discarded – undo
298 298
     {
299 299
         foreach ($options as $option => $value)
300 300
         {
301
-            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option))
302
-                $this->{'set'.$option}($value);
301
+            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option))
302
+                $this->{'set' . $option}($value);
303 303
         }
304 304
     }
305 305
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -209,8 +209,9 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function getArrayResult()
211 211
     {
212
-        if ($this->arrayResult)
213
-            return $this->arrayResult;
212
+        if ($this->arrayResult) {
213
+                    return $this->arrayResult;
214
+        }
214 215
 
215 216
         return $this->toArray();
216 217
     }
@@ -298,8 +299,9 @@  discard block
 block discarded – undo
298 299
     {
299 300
         foreach ($options as $option => $value)
300 301
         {
301
-            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option))
302
-                $this->{'set'.$option}($value);
302
+            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) {
303
+                            $this->{'set'.$option}($value);
304
+            }
303 305
         }
304 306
     }
305 307
 
@@ -343,8 +345,9 @@  discard block
 block discarded – undo
343 345
      */
344 346
     public function reconnect()
345 347
     {
346
-        if (!$this->isConnected())
347
-            throw new \LogicException("Connection was not established");
348
+        if (!$this->isConnected()) {
349
+                    throw new \LogicException("Connection was not established");
350
+        }
348 351
 
349 352
         $this->disconnect();
350 353
         return $this->connect();
@@ -373,8 +376,9 @@  discard block
 block discarded – undo
373 376
      */
374 377
     public function disconnect()
375 378
     {
376
-        if (!$this->isConnected())
377
-            throw new \LogicException("Connection was not established");
379
+        if (!$this->isConnected()) {
380
+                    throw new \LogicException("Connection was not established");
381
+        }
378 382
     }
379 383
 
380 384
     /**
@@ -386,11 +390,13 @@  discard block
 block discarded – undo
386 390
      */
387 391
     public function beginTransaction()
388 392
     {
389
-        if (!$this->isConnected())
390
-            $this->connect();
393
+        if (!$this->isConnected()) {
394
+                    $this->connect();
395
+        }
391 396
 
392
-        if ($this->transac_mode)
393
-            throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]);
397
+        if ($this->transac_mode) {
398
+                    throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]);
399
+        }
394 400
 
395 401
         $this->transac_mode = true;
396 402
     }
@@ -404,16 +410,19 @@  discard block
 block discarded – undo
404 410
      */
405 411
     public function endTransaction()
406 412
     {
407
-        if (!$this->transac_mode)
408
-            throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]);
413
+        if (!$this->transac_mode) {
414
+                    throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]);
415
+        }
409 416
 
410
-        if (is_null($this->transac_result))
411
-            throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]);
417
+        if (is_null($this->transac_result)) {
418
+                    throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]);
419
+        }
412 420
 
413
-        if ($this->transac_result)
414
-            $this->commit();
415
-        else
416
-            $this->rollback();
421
+        if ($this->transac_result) {
422
+                    $this->commit();
423
+        } else {
424
+                    $this->rollback();
425
+        }
417 426
 
418 427
         $this->result = $this->transac_result;
419 428
 
Please login to merge, or discard this patch.
src/Db/Driver/MySQL.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             {
109 109
                 if (is_string($param_values[$i]))
110 110
                     $bind_types .= 's';
111
-                else if(is_float($param_values[$i]))
111
+                else if (is_float($param_values[$i]))
112 112
                     $bind_types .= 'd';
113 113
                 # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?)
114 114
                 else
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             $this->rowsAffected = $this->result->affected_rows;
165 165
 
166 166
         if ($this->transac_mode)
167
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
167
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
168 168
 
169 169
         return $this->result;
170 170
     }
Please login to merge, or discard this patch.
Braces   +46 added lines, -35 removed lines patch added patch discarded remove patch
@@ -24,15 +24,17 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function __construct($options)
26 26
     {
27
-        if (!array_key_exists("dbchar", $options))
28
-            $options["dbchar"] = "utf8";
27
+        if (!array_key_exists("dbchar", $options)) {
28
+                    $options["dbchar"] = "utf8";
29
+        }
29 30
 
30 31
         parent::__construct($options);
31 32
 
32 33
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
33 34
 
34
-        if ($auto_connect)
35
-            $this->connect();
35
+        if ($auto_connect) {
36
+                    $this->connect();
37
+        }
36 38
     }
37 39
 
38 40
     /**
@@ -45,13 +47,15 @@  discard block
 block discarded – undo
45 47
      */
46 48
     public function connect()
47 49
     {
48
-        if (!extension_loaded('mysqli'))
49
-            throw new \RuntimeException("The Mysqli extension is not loaded");
50
+        if (!extension_loaded('mysqli')) {
51
+                    throw new \RuntimeException("The Mysqli extension is not loaded");
52
+        }
50 53
 
51
-        if (!is_null($this->dbport) && !empty($this->dbport))
52
-            $this->dbconn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport);
53
-        else
54
-            $this->dbconn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
54
+        if (!is_null($this->dbport) && !empty($this->dbport)) {
55
+                    $this->dbconn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport);
56
+        } else {
57
+                    $this->dbconn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
58
+        }
55 59
 
56 60
         if ($this->dbconn->connect_errno)
57 61
         {
@@ -61,9 +65,9 @@  discard block
 block discarded – undo
61 65
              * the warning message "Property access is not allowed yet".
62 66
              */
63 67
             throw new Exception\ConnectionException(mysqli_connect_error(), mysqli_connect_errno());
68
+        } else {
69
+                    $this->dbconn->set_charset($this->dbchar);
64 70
         }
65
-        else
66
-            $this->dbconn->set_charset($this->dbchar);
67 71
 
68 72
         return $this->dbconn;
69 73
     }
@@ -106,13 +110,15 @@  discard block
 block discarded – undo
106 110
 
107 111
             for ($i = 0; $i < $n_params; $i++)
108 112
             {
109
-                if (is_string($param_values[$i]))
110
-                    $bind_types .= 's';
111
-                else if(is_float($param_values[$i]))
112
-                    $bind_types .= 'd';
113
+                if (is_string($param_values[$i])) {
114
+                                    $bind_types .= 's';
115
+                } else if(is_float($param_values[$i])) {
116
+                                    $bind_types .= 'd';
117
+                }
113 118
                 # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?)
114
-                else
115
-                    $bind_types .= 's';
119
+                else {
120
+                                    $bind_types .= 's';
121
+                }
116 122
 
117 123
                 $bind_values[] = '$param_values[' . $i . ']';
118 124
             }
@@ -133,12 +139,12 @@  discard block
 block discarded – undo
133 139
                      * It is useful to prevent rollback transactions on insert statements because
134 140
                      * insert statement do not free results.
135 141
                      */
136
-                    if ($res)
137
-                        $this->result = $res;
142
+                    if ($res) {
143
+                                            $this->result = $res;
144
+                    }
138 145
                 }
139 146
             }
140
-        }
141
-        else
147
+        } else
142 148
         {
143 149
             $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL);
144 150
 
@@ -154,17 +160,21 @@  discard block
 block discarded – undo
154 160
             throw new Exception\InvalidQueryException($this->dbconn->error, $this->dbconn->errno);
155 161
         }
156 162
 
157
-        if (is_object($this->result) && property_exists($this->result, 'num_rows'))
158
-            $this->numRows = $this->result->num_rows;
163
+        if (is_object($this->result) && property_exists($this->result, 'num_rows')) {
164
+                    $this->numRows = $this->result->num_rows;
165
+        }
159 166
 
160
-        if (is_object($this->result) && property_exists($this->result, 'field_count'))
161
-            $this->numFields = $this->result->field_count;
167
+        if (is_object($this->result) && property_exists($this->result, 'field_count')) {
168
+                    $this->numFields = $this->result->field_count;
169
+        }
162 170
 
163
-        if (is_object($this->result) && property_exists($this->result, 'affected_rows'))
164
-            $this->rowsAffected = $this->result->affected_rows;
171
+        if (is_object($this->result) && property_exists($this->result, 'affected_rows')) {
172
+                    $this->rowsAffected = $this->result->affected_rows;
173
+        }
165 174
 
166
-        if ($this->transac_mode)
167
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
175
+        if ($this->transac_mode) {
176
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
177
+        }
168 178
 
169 179
         return $this->result;
170 180
     }
@@ -220,9 +230,8 @@  discard block
 block discarded – undo
220 230
             {
221 231
                 $data[] = $row;
222 232
             }
223
-        }
224
-        else
225
-            /*
233
+        } else {
234
+                    /*
226 235
              * "This kind of exception should lead directly to a fix in your code"
227 236
              * So much production tests tell us this error is throwed because developers
228 237
              * execute toArray() before execute().
@@ -230,6 +239,7 @@  discard block
 block discarded – undo
230 239
              * Ref: http://php.net/manual/en/class.logicexception.php
231 240
              */
232 241
             throw new \LogicException('There are not data in the buffer!');
242
+        }
233 243
 
234 244
         $this->arrayResult = $data;
235 245
 
@@ -244,7 +254,8 @@  discard block
 block discarded – undo
244 254
     public function __destruct()
245 255
     {
246 256
         # prevent "Property access is not allowed yet" with @ on failure connections
247
-        if ($this->dbconn !== false && !is_null($this->dbconn))
248
-            @$this->dbconn->close();
257
+        if ($this->dbconn !== false && !is_null($this->dbconn)) {
258
+                    @$this->dbconn->close();
259
+        }
249 260
     }
250 261
 }
251 262
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/Driver/Oracle.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
             ? $this->dbname
53 53
             :
54 54
                 (!is_null($this->dbport) && !empty($this->dbport))
55
-                    ? $this->dbhost .":". $this->dbport ."/". $this->dbname
56
-                    : $this->dbhost ."/". $this->dbname;
55
+                    ? $this->dbhost . ":" . $this->dbport . "/" . $this->dbname
56
+                    : $this->dbhost . "/" . $this->dbname;
57 57
 
58
-        $this->dbconn = @oci_connect($this->dbuser,  $this->dbpass, $connection_string, $this->dbchar);
58
+        $this->dbconn = @oci_connect($this->dbuser, $this->dbpass, $connection_string, $this->dbchar);
59 59
 
60 60
         if ($this->dbconn === false)
61 61
         {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL);
123 123
 
124 124
         // may be throw a Fatal error (Ex: Maximum execution time)
125
-        $r = ($this->transac_mode) ? oci_execute($stid, OCI_NO_AUTO_COMMIT) : oci_execute($stid,  OCI_COMMIT_ON_SUCCESS);
125
+        $r = ($this->transac_mode) ? oci_execute($stid, OCI_NO_AUTO_COMMIT) : oci_execute($stid, OCI_COMMIT_ON_SUCCESS);
126 126
 
127 127
         set_error_handler($prev_error_handler);
128 128
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $this->numFields = oci_num_fields($stid);
144 144
 
145 145
         if ($this->transac_mode)
146
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
146
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
147 147
 
148 148
         return $this->result;
149 149
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
         if ($this->result)
188 188
         {
189
-            while ( ($row = @oci_fetch_array($this->result, OCI_BOTH + OCI_RETURN_NULLS)) !== false )
189
+            while (($row = @oci_fetch_array($this->result, OCI_BOTH + OCI_RETURN_NULLS)) !== false)
190 190
             {
191 191
                 $data[] = $row;
192 192
             }
Please login to merge, or discard this patch.
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,15 +24,17 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function __construct($options)
26 26
     {
27
-        if (!array_key_exists("dbchar", $options))
28
-            $options["dbchar"] = "AL32UTF8";
27
+        if (!array_key_exists("dbchar", $options)) {
28
+                    $options["dbchar"] = "AL32UTF8";
29
+        }
29 30
 
30 31
         parent::__construct($options);
31 32
 
32 33
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
33 34
 
34
-        if ($auto_connect)
35
-            $this->connect();
35
+        if ($auto_connect) {
36
+                    $this->connect();
37
+        }
36 38
     }
37 39
 
38 40
     /**
@@ -45,8 +47,9 @@  discard block
 block discarded – undo
45 47
      */
46 48
     public function connect()
47 49
     {
48
-        if (!extension_loaded('oci8'))
49
-            throw new \RuntimeException("The Oci8 extension is not loaded");
50
+        if (!extension_loaded('oci8')) {
51
+                    throw new \RuntimeException("The Oci8 extension is not loaded");
52
+        }
50 53
 
51 54
         $connection_string = (is_null($this->dbhost) || empty($this->dbhost))
52 55
             ? $this->dbname
@@ -97,14 +100,15 @@  discard block
 block discarded – undo
97 100
                 ];
98 101
 
99 102
                 $this->error($error["message"]);
103
+            } else {
104
+                            $this->error($error["code"], $error["message"]);
100 105
             }
101
-            else
102
-                $this->error($error["code"], $error["message"]);
103 106
 
104
-            if (array_key_exists("code", $error))
105
-                throw new Exception\InvalidQueryException($error["message"], $error["code"]);
106
-            else
107
-                throw new Exception\InvalidQueryException($error["message"]);
107
+            if (array_key_exists("code", $error)) {
108
+                            throw new Exception\InvalidQueryException($error["message"], $error["code"]);
109
+            } else {
110
+                            throw new Exception\InvalidQueryException($error["message"]);
111
+            }
108 112
         }
109 113
 
110 114
         # Bound variables
@@ -142,8 +146,9 @@  discard block
 block discarded – undo
142 146
         $this->numRows = count($rows);
143 147
         $this->numFields = oci_num_fields($stid);
144 148
 
145
-        if ($this->transac_mode)
146
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
149
+        if ($this->transac_mode) {
150
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
151
+        }
147 152
 
148 153
         return $this->result;
149 154
     }
@@ -190,9 +195,8 @@  discard block
 block discarded – undo
190 195
             {
191 196
                 $data[] = $row;
192 197
             }
193
-        }
194
-        else
195
-            /*
198
+        } else {
199
+                    /*
196 200
              * "This kind of exception should lead directly to a fix in your code"
197 201
              * So much production tests tell us this error is throwed because developers
198 202
              * execute toArray() before execute().
@@ -200,6 +204,7 @@  discard block
 block discarded – undo
200 204
              * Ref: http://php.net/manual/en/class.logicexception.php
201 205
              */
202 206
             throw new \LogicException('There are not data in the buffer!');
207
+        }
203 208
 
204 209
         $this->arrayResult = $data;
205 210
 
@@ -213,7 +218,8 @@  discard block
 block discarded – undo
213 218
      */
214 219
     public function __destruct()
215 220
     {
216
-        if ($this->dbconn)
217
-            oci_close($this->dbconn);
221
+        if ($this->dbconn) {
222
+                    oci_close($this->dbconn);
223
+        }
218 224
     }
219 225
 }
220 226
\ 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.
src/Db/Driver/SQLServer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             $r = sqlsrv_execute($this->result);
110 110
         }
111 111
         else
112
-            $r = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
112
+            $r = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET));
113 113
 
114 114
         if (!$r)
115 115
         {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $this->rowsAffected = sqlsrv_rows_affected($this->result);
131 131
 
132 132
         if ($this->transac_mode)
133
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
133
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
134 134
 
135 135
         return $this->result;
136 136
     }
Please login to merge, or discard this patch.
Braces   +23 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,15 +24,17 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function __construct($options)
26 26
     {
27
-        if (!array_key_exists("dbchar", $options))
28
-            $options["dbchar"] = "UTF-8";
27
+        if (!array_key_exists("dbchar", $options)) {
28
+                    $options["dbchar"] = "UTF-8";
29
+        }
29 30
 
30 31
         parent::__construct($options);
31 32
 
32 33
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
33 34
 
34
-        if ($auto_connect)
35
-            $this->connect();
35
+        if ($auto_connect) {
36
+                    $this->connect();
37
+        }
36 38
     }
37 39
 
38 40
     /**
@@ -45,11 +47,13 @@  discard block
 block discarded – undo
45 47
      */
46 48
     public function connect()
47 49
     {
48
-        if (!extension_loaded('sqlsrv'))
49
-            throw new \RuntimeException("The Sqlsrv extension is not loaded");
50
+        if (!extension_loaded('sqlsrv')) {
51
+                    throw new \RuntimeException("The Sqlsrv extension is not loaded");
52
+        }
50 53
 
51
-        if (!is_null($this->dbport) && !empty($this->dbport))
52
-            $this->dbhost .= ', ' . $this->dbport;
54
+        if (!is_null($this->dbport) && !empty($this->dbport)) {
55
+                    $this->dbhost .= ', ' . $this->dbport;
56
+        }
53 57
 
54 58
         $db_info = array("Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpass, "CharacterSet" => $this->dbchar);
55 59
         $this->dbconn = sqlsrv_connect($this->dbhost, $db_info);
@@ -107,9 +111,9 @@  discard block
 block discarded – undo
107 111
             }
108 112
 
109 113
             $r = sqlsrv_execute($this->result);
114
+        } else {
115
+                    $r = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
110 116
         }
111
-        else
112
-            $r = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
113 117
 
114 118
         if (!$r)
115 119
         {
@@ -129,8 +133,9 @@  discard block
 block discarded – undo
129 133
         $this->numFields = sqlsrv_num_fields($this->result);
130 134
         $this->rowsAffected = sqlsrv_rows_affected($this->result);
131 135
 
132
-        if ($this->transac_mode)
133
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
136
+        if ($this->transac_mode) {
137
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
138
+        }
134 139
 
135 140
         return $this->result;
136 141
     }
@@ -197,9 +202,8 @@  discard block
 block discarded – undo
197 202
             {
198 203
                 $data[] = $row;
199 204
             }
200
-        }
201
-        else
202
-            /*
205
+        } else {
206
+                    /*
203 207
              * "This kind of exception should lead directly to a fix in your code"
204 208
              * So much production tests tell us this error is throwed because developers
205 209
              * execute toArray() before execute().
@@ -207,6 +211,7 @@  discard block
 block discarded – undo
207 211
              * Ref: http://php.net/manual/en/class.logicexception.php
208 212
              */
209 213
             throw new \LogicException('There are not data in the buffer!');
214
+        }
210 215
 
211 216
         $this->arrayResult = $data;
212 217
 
@@ -220,7 +225,8 @@  discard block
 block discarded – undo
220 225
      */
221 226
     public function __destruct()
222 227
     {
223
-        if ($this->dbconn)
224
-            sqlsrv_close($this->dbconn);
228
+        if ($this->dbconn) {
229
+                    sqlsrv_close($this->dbconn);
230
+        }
225 231
     }
226 232
 }
227 233
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/SQLFunction.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,8 +77,9 @@
 block discarded – undo
77 77
 
78 78
         foreach ($arguments as $key => $arg)
79 79
         {
80
-            if (is_string($arg))
81
-                $arguments[$key] = "'$arg'";
80
+            if (is_string($arg)) {
81
+                            $arguments[$key] = "'$arg'";
82
+            }
82 83
         }
83 84
 
84 85
         $arguments = implode(", ", array_values($arguments));
Please login to merge, or discard this patch.