Passed
Push — master ( 4562cc...97f943 )
by Darío
04:34
created
src/Db/Driver/SQLServer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         else
133 133
         {
134 134
             if ($isSelectStm)
135
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
135
+                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET));
136 136
             else
137 137
                 $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
138 138
         }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $this->rowsAffected = sqlsrv_rows_affected($this->result);
159 159
 
160 160
         if ($this->transac_mode)
161
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
161
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
162 162
 
163 163
         return $this->result;
164 164
     }
Please login to merge, or discard this 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);
@@ -128,13 +132,13 @@  discard block
 block discarded – undo
128 132
             }
129 133
 
130 134
             $exec = sqlsrv_execute($stmt);
131
-        }
132
-        else
135
+        } else
133 136
         {
134
-            if ($isSelectStm)
135
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
136
-            else
137
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
137
+            if ($isSelectStm) {
138
+                            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
139
+            } else {
140
+                            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
141
+            }
138 142
         }
139 143
 
140 144
         if ($exec === false)
@@ -154,11 +158,13 @@  discard block
 block discarded – undo
154 158
         $this->numRows = sqlsrv_has_rows($this->result) ? sqlsrv_num_rows($this->result) : $this->numRows;
155 159
         $this->numFields = sqlsrv_num_fields($this->result);
156 160
 
157
-        if (!$isSelectStm)
158
-            $this->rowsAffected = sqlsrv_rows_affected($this->result);
161
+        if (!$isSelectStm) {
162
+                    $this->rowsAffected = sqlsrv_rows_affected($this->result);
163
+        }
159 164
 
160
-        if ($this->transac_mode)
161
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
165
+        if ($this->transac_mode) {
166
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
167
+        }
162 168
 
163 169
         return $this->result;
164 170
     }
@@ -225,9 +231,8 @@  discard block
 block discarded – undo
225 231
             {
226 232
                 $data[] = $row;
227 233
             }
228
-        }
229
-        else
230
-            /*
234
+        } else {
235
+                    /*
231 236
              * "This kind of exception should lead directly to a fix in your code"
232 237
              * So much production tests tell us this error is throwed because developers
233 238
              * execute toArray() before execute().
@@ -235,6 +240,7 @@  discard block
 block discarded – undo
235 240
              * Ref: http://php.net/manual/en/class.logicexception.php
236 241
              */
237 242
             throw new \LogicException('There are not data in the buffer!');
243
+        }
238 244
 
239 245
         $this->arrayResult = $data;
240 246
 
@@ -248,7 +254,8 @@  discard block
 block discarded – undo
248 254
      */
249 255
     public function __destruct()
250 256
     {
251
-        if ($this->dbconn)
252
-            sqlsrv_close($this->dbconn);
257
+        if ($this->dbconn) {
258
+                    sqlsrv_close($this->dbconn);
259
+        }
253 260
     }
254 261
 }
255 262
\ No newline at end of file
Please login to merge, or discard this patch.