Passed
Push — master ( 2d92e4...0d56ed )
by Darío
01:37
created
src/Db/TableGateway/AbstractTableGateway.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,8 @@
 block discarded – undo
73 73
     {
74 74
         $this->currentDriverIdentifier = $connection_identifier;
75 75
 
76
-        if (!isset(self::$drivers[$connection_identifier]))
77
-            self::$drivers[$connection_identifier] = new DriverAdapter($connection_identifier, $auto_connect);
76
+        if (!isset(self::$drivers[$connection_identifier])) {
77
+                    self::$drivers[$connection_identifier] = new DriverAdapter($connection_identifier, $auto_connect);
78
+        }
78 79
     }
79 80
 }
80 81
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/TableGateway/EntityAdapter.php 1 patch
Braces   +21 added lines, -16 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $result = $this->tableGateway->select($where);
60 60
 
61
-        if (!count($result))
62
-            return $result;
61
+        if (!count($result)) {
62
+                    return $result;
63
+        }
63 64
 
64 65
         $array_result = [];
65 66
 
@@ -69,8 +70,9 @@  discard block
 block discarded – undo
69 70
 
70 71
             foreach ($row as $key => $value)
71 72
             {
72
-                if (is_string($key))
73
-                    $filtered_array[$key] = $value;
73
+                if (is_string($key)) {
74
+                                    $filtered_array[$key] = $value;
75
+                }
74 76
             }
75 77
 
76 78
             $user_entity = get_class($this->tableGateway->getEntity());
@@ -94,10 +96,11 @@  discard block
 block discarded – undo
94 96
      */
95 97
     public function insert($entity)
96 98
     {
97
-        if ($entity instanceof Entity)
98
-            $entity = get_object_vars($entity);
99
-        else if (!is_array($entity))
100
-            throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected");
99
+        if ($entity instanceof Entity) {
100
+                    $entity = get_object_vars($entity);
101
+        } else if (!is_array($entity)) {
102
+                    throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected");
103
+        }
101 104
 
102 105
         $this->parseEntity($entity);
103 106
 
@@ -126,14 +129,15 @@  discard block
 block discarded – undo
126 129
 
127 130
             foreach ($entity as $key => $value)
128 131
             {
129
-                if (in_array($key, $changedFields))
130
-                    $fieldsToModify[$key] = $value;
132
+                if (in_array($key, $changedFields)) {
133
+                                    $fieldsToModify[$key] = $value;
134
+                }
131 135
             }
132 136
 
133 137
             $entity = $fieldsToModify;
138
+        } else if (!is_array($entity)) {
139
+                    throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected");
134 140
         }
135
-        else if (!is_array($entity))
136
-            throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected");
137 141
 
138 142
         $this->parseEntity($entity);
139 143
 
@@ -152,10 +156,11 @@  discard block
 block discarded – undo
152 156
      */
153 157
     public function delete($entity)
154 158
     {
155
-        if ($entity instanceof Entity)
156
-            $entity = get_object_vars($entity);
157
-        else if (!is_array($entity))
158
-            throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected");
159
+        if ($entity instanceof Entity) {
160
+                    $entity = get_object_vars($entity);
161
+        } else if (!is_array($entity)) {
162
+                    throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected");
163
+        }
159 164
 
160 165
         return $this->tableGateway->delete($entity);
161 166
     }
Please login to merge, or discard this patch.
src/Mvc/AbstractionController.php 1 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,10 +363,11 @@  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
 
@@ -368,10 +375,11 @@  discard block
 block discarded – undo
368 375
 
369 376
             for ($i = 0; $i < $vars_count; $i++)
370 377
             {
371
-                if (array_key_exists($i, $values))
372
-                    $_GET[$vars[$i]] = $values[$i];
373
-                else
374
-                    $_GET[$vars[$i]] = '';
378
+                if (array_key_exists($i, $values)) {
379
+                                    $_GET[$vars[$i]] = $values[$i];
380
+                } else {
381
+                                    $_GET[$vars[$i]] = '';
382
+                }
375 383
             }
376 384
 
377 385
             unset($_GET["params"]);
Please login to merge, or discard this patch.
src/Pear/Mail.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -74,18 +74,21 @@  discard block
 block discarded – undo
74 74
     {
75 75
         @include_once 'System.php';
76 76
 
77
-        if (!class_exists('System', false))
78
-            throw new \RuntimeException("PEAR is not installed in your system!");
77
+        if (!class_exists('System', false)) {
78
+                    throw new \RuntimeException("PEAR is not installed in your system!");
79
+        }
79 80
 
80 81
         include_once 'Net/SMTP.php';
81 82
 
82
-        if (!class_exists('\Net_SMTP', false))
83
-            throw new \RuntimeException("PEAR::Net_SMTP is not installed!");
83
+        if (!class_exists('\Net_SMTP', false)) {
84
+                    throw new \RuntimeException("PEAR::Net_SMTP is not installed!");
85
+        }
84 86
 
85 87
         @include_once 'Mail.php';
86 88
 
87
-        if (!class_exists('\Mail', false))
88
-            throw new \RuntimeException("PEAR::Mail is not installed!");
89
+        if (!class_exists('\Mail', false)) {
90
+                    throw new \RuntimeException("PEAR::Mail is not installed!");
91
+        }
89 92
     }
90 93
 
91 94
     /**
@@ -98,8 +101,9 @@  discard block
 block discarded – undo
98 101
      */
99 102
     protected function error($code, $message = null)
100 103
     {
101
-        if (!array_key_exists($code, $this->errors))
102
-            $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message;
104
+        if (!array_key_exists($code, $this->errors)) {
105
+                    $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message;
106
+        }
103 107
     }
104 108
 
105 109
     /**
Please login to merge, or discard this patch.
src/Network/Socket/AbstractSocket.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,9 @@
 block discarded – undo
108 108
     {
109 109
         foreach ($options as $option => $value)
110 110
         {
111
-            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option))
112
-            $this->{'set'.$option}($value);
111
+            if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) {
112
+                        $this->{'set'.$option}($value);
113
+            }
113 114
         }
114 115
 
115 116
         if (!($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP)))
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
@@ -107,11 +107,12 @@
 block discarded – undo
107 107
             {
108 108
                 $this->$prop = $value;
109 109
 
110
-                if (!in_array($prop, $this->changedFields))
111
-                    $this->changedFields[] = $prop;
110
+                if (!in_array($prop, $this->changedFields)) {
111
+                                    $this->changedFields[] = $prop;
112
+                }
113
+            } else {
114
+                            throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '");
112 115
             }
113
-            else
114
-                throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '");
115 116
         }
116 117
     }
117 118
 
Please login to merge, or discard this patch.
src/Db/Driver/Oracle.php 1 patch
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -31,15 +31,17 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct($options)
33 33
     {
34
-        if (!array_key_exists("dbchar", $options))
35
-            $options["dbchar"] = "AL32UTF8";
34
+        if (!array_key_exists("dbchar", $options)) {
35
+                    $options["dbchar"] = "AL32UTF8";
36
+        }
36 37
 
37 38
         parent::__construct($options);
38 39
 
39 40
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
40 41
 
41
-        if ($auto_connect)
42
-            $this->connect();
42
+        if ($auto_connect) {
43
+                    $this->connect();
44
+        }
43 45
     }
44 46
 
45 47
     /**
@@ -52,8 +54,9 @@  discard block
 block discarded – undo
52 54
      */
53 55
     public function connect()
54 56
     {
55
-        if (!extension_loaded('oci8'))
56
-            throw new \RuntimeException("The Oci8 extension is not loaded");
57
+        if (!extension_loaded('oci8')) {
58
+                    throw new \RuntimeException("The Oci8 extension is not loaded");
59
+        }
57 60
 
58 61
         $connection_string = (is_null($this->dbhost) || empty($this->dbhost))
59 62
             ? $this->dbname
@@ -106,14 +109,15 @@  discard block
 block discarded – undo
106 109
                 ];
107 110
 
108 111
                 $this->error($error["message"]);
112
+            } else {
113
+                            $this->error($error["code"], $error["message"]);
109 114
             }
110
-            else
111
-                $this->error($error["code"], $error["message"]);
112 115
 
113
-            if (array_key_exists("code", $error))
114
-                throw new Exception\InvalidQueryException($error["message"], $error["code"]);
115
-            else
116
-                throw new Exception\InvalidQueryException($error["message"]);
116
+            if (array_key_exists("code", $error)) {
117
+                            throw new Exception\InvalidQueryException($error["message"], $error["code"]);
118
+            } else {
119
+                            throw new Exception\InvalidQueryException($error["message"]);
120
+            }
117 121
         }
118 122
 
119 123
         # Bound variables
@@ -151,8 +155,9 @@  discard block
 block discarded – undo
151 155
         $this->numRows = count($rows);
152 156
         $this->numFields = oci_num_fields($stid);
153 157
 
154
-        if ($this->transac_mode)
155
-            $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid;
158
+        if ($this->transac_mode) {
159
+                    $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid;
160
+        }
156 161
 
157 162
         $this->result = $stid;
158 163
 
@@ -201,9 +206,8 @@  discard block
 block discarded – undo
201 206
             {
202 207
                 $data[] = $row;
203 208
             }
204
-        }
205
-        else
206
-            /*
209
+        } else {
210
+                    /*
207 211
              * "This kind of exception should lead directly to a fix in your code"
208 212
              * So much production tests tell us this error is throwed because developers
209 213
              * execute toArray() before execute().
@@ -211,6 +215,7 @@  discard block
 block discarded – undo
211 215
              * Ref: http://php.net/manual/en/class.logicexception.php
212 216
              */
213 217
             throw new \LogicException('There are not data in the buffer!');
218
+        }
214 219
 
215 220
         $this->arrayResult = $data;
216 221
 
@@ -224,7 +229,8 @@  discard block
 block discarded – undo
224 229
      */
225 230
     public function __destruct()
226 231
     {
227
-        if ($this->dbconn)
228
-            oci_close($this->dbconn);
232
+        if ($this->dbconn) {
233
+                    oci_close($this->dbconn);
234
+        }
229 235
     }
230 236
 }
231 237
\ 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
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
             {
74 74
                 $k++;
75 75
 
76
-                if (is_null($value))
77
-                    $parsed_where[] = "$key IS NULL";
78
-                elseif ($value instanceof SQLFunction)
79
-                    $parsed_where[] = "$key = " . $value->getStatement();
80
-                elseif (is_array($value))
76
+                if (is_null($value)) {
77
+                                    $parsed_where[] = "$key IS NULL";
78
+                } elseif ($value instanceof SQLFunction) {
79
+                                    $parsed_where[] = "$key = " . $value->getStatement();
80
+                } elseif (is_array($value))
81 81
                 {
82 82
                     $parsed_in = [];
83 83
 
@@ -100,8 +100,7 @@  discard block
 block discarded – undo
100 100
                     }
101 101
 
102 102
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
103
-                }
104
-                else
103
+                } else
105 104
                 {
106 105
                     switch ($driver)
107 106
                     {
@@ -119,18 +118,19 @@  discard block
 block discarded – undo
119 118
             }
120 119
 
121 120
             $where = "WHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
121
+        } else {
122
+                    $where = "";
122 123
         }
123
-        else
124
-            $where = "";
125 124
 
126 125
         $table = $this->entity->getTableName();
127 126
 
128 127
         $sql = "SELECT * \r\nFROM {$table}\r\n$where";
129 128
 
130
-        if (count($bind_values))
131
-            $this->getDriver()->getDb()->execute($sql, $bind_values);
132
-        else
133
-            $this->getDriver()->getDb()->execute($sql);
129
+        if (count($bind_values)) {
130
+                    $this->getDriver()->getDb()->execute($sql, $bind_values);
131
+        } else {
132
+                    $this->getDriver()->getDb()->execute($sql);
133
+        }
134 134
 
135 135
         return $this->getDriver()->getDb()->getArrayResult();
136 136
     }
@@ -147,8 +147,9 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function insert(Array $data)
149 149
     {
150
-        if (!count($data))
151
-            throw new \LogicException("Missing values for INSERT statement!");
150
+        if (!count($data)) {
151
+                    throw new \LogicException("Missing values for INSERT statement!");
152
+        }
152 153
 
153 154
         $bind_values = [];
154 155
 
@@ -171,11 +172,11 @@  discard block
 block discarded – undo
171 172
                 continue;
172 173
             }
173 174
 
174
-            if (is_null($value))
175
-                $value = "NULL";
176
-            elseif ($value instanceof SQLFunction)
177
-                $value = $value->getStatement();
178
-            else {
175
+            if (is_null($value)) {
176
+                            $value = "NULL";
177
+            } elseif ($value instanceof SQLFunction) {
178
+                            $value = $value->getStatement();
179
+            } else {
179 180
 
180 181
                 switch ($driver)
181 182
                 {
@@ -225,11 +226,13 @@  discard block
 block discarded – undo
225 226
     {
226 227
         $parsed_set = [];
227 228
 
228
-        if (!count($set))
229
-            throw new \LogicException("You cannot update rows without SET clause");
229
+        if (!count($set)) {
230
+                    throw new \LogicException("You cannot update rows without SET clause");
231
+        }
230 232
 
231
-        if (!count($where))
232
-            throw new SecurityException("You cannot update rows without WHERE clause!");
233
+        if (!count($where)) {
234
+                    throw new SecurityException("You cannot update rows without WHERE clause!");
235
+        }
233 236
 
234 237
         $bind_values = [];
235 238
 
@@ -241,11 +244,11 @@  discard block
 block discarded – undo
241 244
         {
242 245
             $k++;
243 246
 
244
-            if (is_null($value))
245
-                $parsed_set[] = "$key = NULL";
246
-            elseif ($value instanceof SQLFunction)
247
-                $parsed_set[] = "$key = " . $value->getStatement();
248
-            elseif (is_array($value))
247
+            if (is_null($value)) {
248
+                            $parsed_set[] = "$key = NULL";
249
+            } elseif ($value instanceof SQLFunction) {
250
+                            $parsed_set[] = "$key = " . $value->getStatement();
251
+            } elseif (is_array($value))
249 252
             {
250 253
                 $parsed_in = [];
251 254
 
@@ -256,8 +259,9 @@  discard block
 block discarded – undo
256 259
                         case 'Oci8':
257 260
 
258 261
                             # [POSSIBLE BUG] - To Future revision (What about non-string values ?)
259
-                            if (is_string($in_value))
260
-                                $parsed_in[] = ":$k";
262
+                            if (is_string($in_value)) {
263
+                                                            $parsed_in[] = ":$k";
264
+                            }
261 265
 
262 266
                             $bind_values[":$k"] = $in_value;
263 267
                             break;
@@ -272,8 +276,7 @@  discard block
 block discarded – undo
272 276
                 }
273 277
 
274 278
                 $parsed_set[] = "$key IN (" . implode(", ", $parsed_in) . ")";
275
-            }
276
-            else
279
+            } else
277 280
             {
278 281
                 switch ($driver)
279 282
                 {
@@ -298,11 +301,11 @@  discard block
 block discarded – undo
298 301
         {
299 302
             $k++;
300 303
 
301
-            if (is_null($value))
302
-                $parsed_where[] = "$key IS NULL";
303
-            elseif ($value instanceof SQLFunction)
304
-                $parsed_where[] = "$key = " . $value->getStatement();
305
-            elseif (is_array($value))
304
+            if (is_null($value)) {
305
+                            $parsed_where[] = "$key IS NULL";
306
+            } elseif ($value instanceof SQLFunction) {
307
+                            $parsed_where[] = "$key = " . $value->getStatement();
308
+            } elseif (is_array($value))
306 309
             {
307 310
                 $parsed_in = [];
308 311
 
@@ -325,8 +328,7 @@  discard block
 block discarded – undo
325 328
                 }
326 329
 
327 330
                 $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
328
-            }
329
-            else
331
+            } else
330 332
             {
331 333
                 switch ($driver)
332 334
                 {
@@ -378,11 +380,11 @@  discard block
 block discarded – undo
378 380
             {
379 381
                 $k++;
380 382
 
381
-                if (is_null($value))
382
-                    $parsed_where[] = "$key IS NULL";
383
-                elseif ($value instanceof SQLFunction)
384
-                    $parsed_where[] = "$key = " . $value->getStatement();
385
-                elseif (is_array($value))
383
+                if (is_null($value)) {
384
+                                    $parsed_where[] = "$key IS NULL";
385
+                } elseif ($value instanceof SQLFunction) {
386
+                                    $parsed_where[] = "$key = " . $value->getStatement();
387
+                } elseif (is_array($value))
386 388
                 {
387 389
                     $parsed_in = [];
388 390
 
@@ -405,8 +407,7 @@  discard block
 block discarded – undo
405 407
                     }
406 408
 
407 409
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
408
-                }
409
-                else
410
+                } else
410 411
                 {
411 412
                     switch ($driver)
412 413
                     {
@@ -424,9 +425,9 @@  discard block
 block discarded – undo
424 425
             }
425 426
 
426 427
             $where = "\r\nWHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
428
+        } else {
429
+                    throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
427 430
         }
428
-        else
429
-            throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
430 431
 
431 432
         $table = $this->entity->getTableName();
432 433
 
Please login to merge, or discard this patch.
src/Db/Driver/SQLServer.php 1 patch
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,15 +31,17 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct($options)
33 33
     {
34
-        if (!array_key_exists("dbchar", $options))
35
-            $options["dbchar"] = "UTF-8";
34
+        if (!array_key_exists("dbchar", $options)) {
35
+                    $options["dbchar"] = "UTF-8";
36
+        }
36 37
 
37 38
         parent::__construct($options);
38 39
 
39 40
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
40 41
 
41
-        if ($auto_connect)
42
-            $this->connect();
42
+        if ($auto_connect) {
43
+                    $this->connect();
44
+        }
43 45
     }
44 46
 
45 47
     /**
@@ -52,11 +54,13 @@  discard block
 block discarded – undo
52 54
      */
53 55
     public function connect()
54 56
     {
55
-        if (!extension_loaded('sqlsrv'))
56
-            throw new \RuntimeException("The Sqlsrv extension is not loaded");
57
+        if (!extension_loaded('sqlsrv')) {
58
+                    throw new \RuntimeException("The Sqlsrv extension is not loaded");
59
+        }
57 60
 
58
-        if (!is_null($this->dbport) && !empty($this->dbport))
59
-            $this->dbhost .= ', ' . $this->dbport;
61
+        if (!is_null($this->dbport) && !empty($this->dbport)) {
62
+                    $this->dbhost .= ', ' . $this->dbport;
63
+        }
60 64
 
61 65
         $db_info = array("Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpass, "CharacterSet" => $this->dbchar);
62 66
         $conn = sqlsrv_connect($this->dbhost, $db_info);
@@ -137,13 +141,13 @@  discard block
 block discarded – undo
137 141
             }
138 142
 
139 143
             $exec = sqlsrv_execute($stmt);
140
-        }
141
-        else
144
+        } else
142 145
         {
143
-            if ($isSelectStm)
144
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
145
-            else
146
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
146
+            if ($isSelectStm) {
147
+                            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
148
+            } else {
149
+                            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
150
+            }
147 151
         }
148 152
 
149 153
         if ($exec === false)
@@ -163,11 +167,13 @@  discard block
 block discarded – undo
163 167
         $this->numRows = sqlsrv_has_rows($this->result) ? sqlsrv_num_rows($this->result) : $this->numRows;
164 168
         $this->numFields = sqlsrv_num_fields($this->result);
165 169
 
166
-        if ($isInsertStm || $isUpdateStm || $isDeleteStm)
167
-            $this->rowsAffected = sqlsrv_rows_affected($this->result);
170
+        if ($isInsertStm || $isUpdateStm || $isDeleteStm) {
171
+                    $this->rowsAffected = sqlsrv_rows_affected($this->result);
172
+        }
168 173
 
169
-        if ($this->transac_mode)
170
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
174
+        if ($this->transac_mode) {
175
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
176
+        }
171 177
 
172 178
         return $this->result;
173 179
     }
@@ -234,9 +240,8 @@  discard block
 block discarded – undo
234 240
             {
235 241
                 $data[] = $row;
236 242
             }
237
-        }
238
-        else
239
-            /*
243
+        } else {
244
+                    /*
240 245
              * "This kind of exception should lead directly to a fix in your code"
241 246
              * So much production tests tell us this error is throwed because developers
242 247
              * execute toArray() before execute().
@@ -244,6 +249,7 @@  discard block
 block discarded – undo
244 249
              * Ref: http://php.net/manual/en/class.logicexception.php
245 250
              */
246 251
             throw new \LogicException('There are not data in the buffer!');
252
+        }
247 253
 
248 254
         $this->arrayResult = $data;
249 255
 
@@ -257,7 +263,8 @@  discard block
 block discarded – undo
257 263
      */
258 264
     public function __destruct()
259 265
     {
260
-        if ($this->dbconn)
261
-            sqlsrv_close($this->dbconn);
266
+        if ($this->dbconn) {
267
+                    sqlsrv_close($this->dbconn);
268
+        }
262 269
     }
263 270
 }
264 271
\ No newline at end of file
Please login to merge, or discard this patch.