Passed
Branch master (800486)
by Darío
02:44
created
src/Db/Driver/SQLServer.php 1 patch
Braces   +23 added lines, -17 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);
@@ -116,9 +120,9 @@  discard block
 block discarded – undo
116 120
             }
117 121
 
118 122
             $exec = sqlsrv_execute($stmt);
123
+        } else {
124
+                    $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
119 125
         }
120
-        else
121
-            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
122 126
 
123 127
         if ($exec === false)
124 128
         {
@@ -138,8 +142,9 @@  discard block
 block discarded – undo
138 142
         $this->numFields = sqlsrv_num_fields($this->result);
139 143
         $this->rowsAffected = sqlsrv_rows_affected($this->result);
140 144
 
141
-        if ($this->transac_mode)
142
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
145
+        if ($this->transac_mode) {
146
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
147
+        }
143 148
 
144 149
         return $this->result;
145 150
     }
@@ -206,9 +211,8 @@  discard block
 block discarded – undo
206 211
             {
207 212
                 $data[] = $row;
208 213
             }
209
-        }
210
-        else
211
-            /*
214
+        } else {
215
+                    /*
212 216
              * "This kind of exception should lead directly to a fix in your code"
213 217
              * So much production tests tell us this error is throwed because developers
214 218
              * execute toArray() before execute().
@@ -216,6 +220,7 @@  discard block
 block discarded – undo
216 220
              * Ref: http://php.net/manual/en/class.logicexception.php
217 221
              */
218 222
             throw new \LogicException('There are not data in the buffer!');
223
+        }
219 224
 
220 225
         $this->arrayResult = $data;
221 226
 
@@ -229,7 +234,8 @@  discard block
 block discarded – undo
229 234
      */
230 235
     public function __destruct()
231 236
     {
232
-        if ($this->dbconn)
233
-            sqlsrv_close($this->dbconn);
237
+        if ($this->dbconn) {
238
+                    sqlsrv_close($this->dbconn);
239
+        }
234 240
     }
235 241
 }
236 242
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/Driver/AbstractDriver.php 1 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 (count($this->arrayResult))
213
-            return $this->arrayResult;
212
+        if (count($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/Network/Socket/AbstractSocket.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         }
122 122
 
123 123
         $this->socket = $socket;
124
-	}
124
+    }
125 125
 
126 126
     /**
127 127
      * Binds the socket
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
      *
146 146
      * @return null
147 147
      */
148
-	public function close()
149
-	{
148
+    public function close()
149
+    {
150 150
         return socket_close($this->socket);
151
-	}
151
+    }
152 152
 }
153 153
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,8 @@
 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
         if (!($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP)))
Please login to merge, or discard this 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.