Passed
Branch master (f0e7b7)
by Darío
02:39 queued 11s
created
src/Db/Driver/SQLServer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             $exec = sqlsrv_execute($stmt);
117 117
         }
118 118
         else
119
-            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
119
+            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET));
120 120
 
121 121
         if ($exec === false)
122 122
         {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         $this->rowsAffected = sqlsrv_rows_affected($this->result);
138 138
 
139 139
         if ($this->transac_mode)
140
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
140
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
141 141
 
142 142
         return $this->result;
143 143
     }
Please login to merge, or discard this 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
         $this->dbconn = sqlsrv_connect($this->dbhost, $db_info);
@@ -114,9 +118,9 @@  discard block
 block discarded – undo
114 118
             }
115 119
 
116 120
             $exec = sqlsrv_execute($stmt);
121
+        } else {
122
+                    $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
117 123
         }
118
-        else
119
-            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
120 124
 
121 125
         if ($exec === false)
122 126
         {
@@ -136,8 +140,9 @@  discard block
 block discarded – undo
136 140
         $this->numFields = sqlsrv_num_fields($this->result);
137 141
         $this->rowsAffected = sqlsrv_rows_affected($this->result);
138 142
 
139
-        if ($this->transac_mode)
140
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
143
+        if ($this->transac_mode) {
144
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
145
+        }
141 146
 
142 147
         return $this->result;
143 148
     }
@@ -204,9 +209,8 @@  discard block
 block discarded – undo
204 209
             {
205 210
                 $data[] = $row;
206 211
             }
207
-        }
208
-        else
209
-            /*
212
+        } else {
213
+                    /*
210 214
              * "This kind of exception should lead directly to a fix in your code"
211 215
              * So much production tests tell us this error is throwed because developers
212 216
              * execute toArray() before execute().
@@ -214,6 +218,7 @@  discard block
 block discarded – undo
214 218
              * Ref: http://php.net/manual/en/class.logicexception.php
215 219
              */
216 220
             throw new \LogicException('There are not data in the buffer!');
221
+        }
217 222
 
218 223
         $this->arrayResult = $data;
219 224
 
@@ -227,7 +232,8 @@  discard block
 block discarded – undo
227 232
      */
228 233
     public function __destruct()
229 234
     {
230
-        if ($this->dbconn)
231
-            sqlsrv_close($this->dbconn);
235
+        if ($this->dbconn) {
236
+                    sqlsrv_close($this->dbconn);
237
+        }
232 238
     }
233 239
 }
234 240
\ No newline at end of file
Please login to merge, or discard this patch.
src/Network/Socket/Server.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @return string
28 28
      */
29
-	public function read($socket)
30
-	{
31
-		if (($message = @socket_read($socket, 1024)) === false)
32
-		{
33
-			$errno = socket_last_error();
34
-			$this->error($errno, socket_strerror($errno));
29
+    public function read($socket)
30
+    {
31
+        if (($message = @socket_read($socket, 1024)) === false)
32
+        {
33
+            $errno = socket_last_error();
34
+            $this->error($errno, socket_strerror($errno));
35 35
 
36
-			throw new \RuntimeException("Could not read message from client socket");
37
-		}
36
+            throw new \RuntimeException("Could not read message from client socket");
37
+        }
38 38
 
39
-		return $message;
40
-	}
39
+        return $message;
40
+    }
41 41
 
42 42
     /**
43 43
      * Sends a message to client socket
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
      *
50 50
      * @return integer
51 51
      */
52
-	public function send($socket, $message)
53
-	{
54
-		if (($bytes = @socket_write($socket, $message, strlen($message))) === false)
55
-		{
56
-			$errno = socket_last_error();
57
-			$this->error($errno, socket_strerror($errno));
52
+    public function send($socket, $message)
53
+    {
54
+        if (($bytes = @socket_write($socket, $message, strlen($message))) === false)
55
+        {
56
+            $errno = socket_last_error();
57
+            $this->error($errno, socket_strerror($errno));
58 58
 
59
-			throw new \RuntimeException("Could not send message to the client socket");
60
-		}
59
+            throw new \RuntimeException("Could not send message to the client socket");
60
+        }
61 61
 
62
-		return $bytes;
63
-	}
62
+        return $bytes;
63
+    }
64 64
 
65 65
     /**
66 66
      * Sets socket to listening
@@ -71,54 +71,54 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return boolean
73 73
      */
74
-	public function listen(Array $eventHandlers = array())
75
-	{
76
-		$event = $eventHandlers;
77
-		$clousure = function(){};
74
+    public function listen(Array $eventHandlers = array())
75
+    {
76
+        $event = $eventHandlers;
77
+        $clousure = function(){};
78 78
 
79
-		if (!array_key_exists('success', $event))
80
-			$event["success"] = $clousure;
79
+        if (!array_key_exists('success', $event))
80
+            $event["success"] = $clousure;
81 81
 
82
-		if (!array_key_exists('error', $event))
83
-			$event["error"] = $clousure;
82
+        if (!array_key_exists('error', $event))
83
+            $event["error"] = $clousure;
84 84
 
85
-		$listener = false;
85
+        $listener = false;
86 86
 
87
-		if (!($listener = @socket_listen($this->socket, 30)))
88
-		{
89
-			$errno = socket_last_error();
90
-			$this->error($errno, socket_strerror($errno));
87
+        if (!($listener = @socket_listen($this->socket, 30)))
88
+        {
89
+            $errno = socket_last_error();
90
+            $this->error($errno, socket_strerror($errno));
91 91
 
92
-			throw new \RuntimeException("Could not set socket to listen");
93
-		}
94
-		else {
92
+            throw new \RuntimeException("Could not set socket to listen");
93
+        }
94
+        else {
95 95
 
96
-			echo "\n";
97
-			echo "Server Started : " . date('Y-m-d H:i:s') . "\n";
98
-			echo "Master socket  : " . $this->socket . "\n";
99
-			echo "Listening on   : " . $this->host . " port " . $this->port . "\n\n";
96
+            echo "\n";
97
+            echo "Server Started : " . date('Y-m-d H:i:s') . "\n";
98
+            echo "Master socket  : " . $this->socket . "\n";
99
+            echo "Listening on   : " . $this->host . " port " . $this->port . "\n\n";
100 100
 
101
-			$socket = $this->socket;
101
+            $socket = $this->socket;
102 102
 
103
-			if (!($spawn = @socket_accept($this->socket)))
104
-			{
105
-				$errno = socket_last_error();
106
-				$this->error($errno, socket_strerror($errno));
103
+            if (!($spawn = @socket_accept($this->socket)))
104
+            {
105
+                $errno = socket_last_error();
106
+                $this->error($errno, socket_strerror($errno));
107 107
 
108
-				throw new \RuntimeException("Could not accept incoming connection");
109
-			}
108
+                throw new \RuntimeException("Could not accept incoming connection");
109
+            }
110 110
 
111
-			$input = $this->read($spawn);
111
+            $input = $this->read($spawn);
112 112
 
113
-			$input = trim($input);
114
-			call_user_func($event["success"], $input, $this, $spawn);
113
+            $input = trim($input);
114
+            call_user_func($event["success"], $input, $this, $spawn);
115 115
 
116
-			socket_close($spawn);
117
-		}
116
+            socket_close($spawn);
117
+        }
118 118
 
119
-		if (!$listener)
120
-			call_user_func($event["error"], $this->getLastError());
119
+        if (!$listener)
120
+            call_user_func($event["error"], $this->getLastError());
121 121
 
122
-		return $listener;
123
-	}
122
+        return $listener;
123
+    }
124 124
 }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.
src/Network/Socket/AbstractSocket.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
             throw new \RuntimeException("Could not create the socket");
121 121
         }
122
-	}
122
+    }
123 123
 
124 124
     /**
125 125
      * Binds the socket
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
      *
144 144
      * @return null
145 145
      */
146
-	public function close()
147
-	{
146
+    public function close()
147
+    {
148 148
         return socket_close($this->socket);
149
-	}
149
+    }
150 150
 }
151 151
\ No newline at end of file
Please login to merge, or discard this patch.