Passed
Branch master (b79870)
by Darío
03:47
created
src/Db/Driver/MySQL.php 1 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 1 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 1 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.
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/TableGateway.php 1 patch
Braces   +45 added lines, -45 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,9 +118,9 @@  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
 
@@ -144,8 +143,9 @@  discard block
 block discarded – undo
144 143
      */
145 144
     public function insert(Array $data)
146 145
     {
147
-        if (!count($data))
148
-            throw new \LogicException("Missing values for INSERT statement!");
146
+        if (!count($data)) {
147
+                    throw new \LogicException("Missing values for INSERT statement!");
148
+        }
149 149
 
150 150
         $bind_values = [];
151 151
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
                 continue;
169 169
             }
170 170
 
171
-            if (is_null($value))
172
-                $value = "NULL";
173
-            elseif ($value instanceof SQLFunction)
174
-                $value = $value->getStatement();
175
-            else {
171
+            if (is_null($value)) {
172
+                            $value = "NULL";
173
+            } elseif ($value instanceof SQLFunction) {
174
+                            $value = $value->getStatement();
175
+            } else {
176 176
 
177 177
                 switch ($driver)
178 178
                 {
@@ -222,11 +222,13 @@  discard block
 block discarded – undo
222 222
     {
223 223
         $parsed_set = [];
224 224
 
225
-        if (!count($set))
226
-            throw new \LogicException("You cannot update rows without SET clause");
225
+        if (!count($set)) {
226
+                    throw new \LogicException("You cannot update rows without SET clause");
227
+        }
227 228
 
228
-        if (!count($where))
229
-            throw new SecurityException("You cannot update rows without WHERE clause!");
229
+        if (!count($where)) {
230
+                    throw new SecurityException("You cannot update rows without WHERE clause!");
231
+        }
230 232
 
231 233
         $bind_values = [];
232 234
 
@@ -238,11 +240,11 @@  discard block
 block discarded – undo
238 240
         {
239 241
             $k++;
240 242
 
241
-            if (is_null($value))
242
-                $parsed_set[] = "$key = NULL";
243
-            elseif ($value instanceof SQLFunction)
244
-                $parsed_set[] = "$key = " . $value->getStatement();
245
-            elseif (is_array($value))
243
+            if (is_null($value)) {
244
+                            $parsed_set[] = "$key = NULL";
245
+            } elseif ($value instanceof SQLFunction) {
246
+                            $parsed_set[] = "$key = " . $value->getStatement();
247
+            } elseif (is_array($value))
246 248
             {
247 249
                 $parsed_in = [];
248 250
 
@@ -253,8 +255,9 @@  discard block
 block discarded – undo
253 255
                         case 'Oci8':
254 256
 
255 257
                             # [POSSIBLE BUG] - To Future revision (What about non-string values ?)
256
-                            if (is_string($in_value))
257
-                                $parsed_in[] = ":$k";
258
+                            if (is_string($in_value)) {
259
+                                                            $parsed_in[] = ":$k";
260
+                            }
258 261
 
259 262
                             $bind_values[":$k"] = $in_value;
260 263
                             break;
@@ -269,8 +272,7 @@  discard block
 block discarded – undo
269 272
                 }
270 273
 
271 274
                 $parsed_set[] = "$key IN (" . implode(", ", $parsed_in) . ")";
272
-            }
273
-            else
275
+            } else
274 276
             {
275 277
                 switch ($driver)
276 278
                 {
@@ -296,11 +298,11 @@  discard block
 block discarded – undo
296 298
         {
297 299
             $k++;
298 300
 
299
-            if (is_null($value))
300
-                $parsed_where[] = "$key IS NULL";
301
-            elseif ($value instanceof SQLFunction)
302
-                $parsed_where[] = "$key = " . $value->getStatement();
303
-            elseif (is_array($value))
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 306
             {
305 307
                 $parsed_in = [];
306 308
 
@@ -323,8 +325,7 @@  discard block
 block discarded – undo
323 325
                 }
324 326
 
325 327
                 $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
326
-            }
327
-            else
328
+            } else
328 329
             {
329 330
                 switch ($driver)
330 331
                 {
@@ -376,11 +377,11 @@  discard block
 block discarded – undo
376 377
             {
377 378
                 $k++;
378 379
 
379
-                if (is_null($value))
380
-                    $parsed_where[] = "$key IS NULL";
381
-                elseif ($value instanceof SQLFunction)
382
-                    $parsed_where[] = "$key = " . $value->getStatement();
383
-                elseif (is_array($value))
380
+                if (is_null($value)) {
381
+                                    $parsed_where[] = "$key IS NULL";
382
+                } elseif ($value instanceof SQLFunction) {
383
+                                    $parsed_where[] = "$key = " . $value->getStatement();
384
+                } elseif (is_array($value))
384 385
                 {
385 386
                     $parsed_in = [];
386 387
 
@@ -403,8 +404,7 @@  discard block
 block discarded – undo
403 404
                     }
404 405
 
405 406
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
406
-                }
407
-                else
407
+                } else
408 408
                 {
409 409
                     switch ($driver)
410 410
                     {
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
             }
423 423
 
424 424
             $where = "\r\nWHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
425
+        } else {
426
+                    throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
425 427
         }
426
-        else
427
-            throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
428 428
 
429 429
         $table = $this->entity->getTableName();
430 430
 
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.