@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | foreach ($filesForHandler as $item) |
85 | 85 | { |
86 | - if ($item != '.' && $item != '..') |
|
87 | - $contents[] = $item; |
|
86 | + if ($item != '.' && $item != '..') { |
|
87 | + $contents[] = $item; |
|
88 | + } |
|
88 | 89 | } |
89 | 90 | |
90 | 91 | $allContents = $contents; |
@@ -99,8 +100,7 @@ discard block |
||
99 | 100 | |
100 | 101 | $this->buffer = $handler.'/'.$i; |
101 | 102 | call_user_func($fileCallback, $this); |
102 | - } |
|
103 | - elseif (is_dir($handler.'/'.$i)) |
|
103 | + } elseif (is_dir($handler.'/'.$i)) |
|
104 | 104 | { |
105 | 105 | $allContents[] = $handler.'/'.$i; |
106 | 106 | |
@@ -109,19 +109,21 @@ discard block |
||
109 | 109 | |
110 | 110 | $directory = scandir($handler); |
111 | 111 | |
112 | - if (!count($directory) < 3) |
|
113 | - $this->buffer = $handler.'/'.$i; |
|
112 | + if (!count($directory) < 3) { |
|
113 | + $this->buffer = $handler.'/'.$i; |
|
114 | + } |
|
114 | 115 | |
115 | 116 | call_user_func($dirCallback, $this); |
116 | 117 | } |
117 | 118 | } |
118 | 119 | } |
120 | + } else { |
|
121 | + throw new Exception("The directory '$handler' does not exists"); |
|
119 | 122 | } |
120 | - else |
|
121 | - throw new Exception("The directory '$handler' does not exists"); |
|
122 | 123 | |
123 | - if (!is_null($callback)) |
|
124 | - call_user_func($callback, $this); |
|
124 | + if (!is_null($callback)) { |
|
125 | + call_user_func($callback, $this); |
|
126 | + } |
|
125 | 127 | |
126 | 128 | return $allContents; |
127 | 129 | } |
@@ -133,10 +135,11 @@ discard block |
||
133 | 135 | */ |
134 | 136 | public function pwd() |
135 | 137 | { |
136 | - if (getcwd()) |
|
137 | - $this->buffer = getcwd(); |
|
138 | - else |
|
139 | - return false; |
|
138 | + if (getcwd()) { |
|
139 | + $this->buffer = getcwd(); |
|
140 | + } else { |
|
141 | + return false; |
|
142 | + } |
|
140 | 143 | |
141 | 144 | return $this->buffer; |
142 | 145 | } |
@@ -155,9 +158,9 @@ discard block |
||
155 | 158 | |
156 | 159 | $path = (is_null($path) || empty($path)) ? '.' : $path; |
157 | 160 | |
158 | - if (is_file($path)) |
|
159 | - $filesToReturn = array($path); |
|
160 | - elseif (is_dir($path)) |
|
161 | + if (is_file($path)) { |
|
162 | + $filesToReturn = array($path); |
|
163 | + } elseif (is_dir($path)) |
|
161 | 164 | { |
162 | 165 | $pathIns = dir($path); |
163 | 166 | |
@@ -179,25 +182,25 @@ discard block |
||
179 | 182 | foreach ($files as $item) { |
180 | 183 | $filesToReturn[] = $item; |
181 | 184 | } |
182 | - } |
|
183 | - else { |
|
185 | + } else { |
|
184 | 186 | while (false !== ($item = $pathIns->read())) { |
185 | 187 | $filesToReturn[] = $item; |
186 | 188 | } |
187 | 189 | $pathIns->close(); |
188 | 190 | } |
189 | - } |
|
190 | - else { |
|
191 | + } else { |
|
191 | 192 | |
192 | 193 | $contents = $this->ls(); |
193 | 194 | |
194 | 195 | foreach ($contents as $item) |
195 | 196 | { |
196 | - if (!empty($path)) |
|
197 | - if (!strlen(stristr($item, $path)) > 0) |
|
197 | + if (!empty($path)) { |
|
198 | + if (!strlen(stristr($item, $path)) > 0) |
|
198 | 199 | continue; |
199 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
200 | - $filesToReturn[] = $item; |
|
200 | + } |
|
201 | + if (strstr($item,'~') === false && $item != '.' && $item != '..') { |
|
202 | + $filesToReturn[] = $item; |
|
203 | + } |
|
201 | 204 | } |
202 | 205 | } |
203 | 206 | |
@@ -217,8 +220,9 @@ discard block |
||
217 | 220 | |
218 | 221 | if (is_dir($path)) |
219 | 222 | { |
220 | - if (chdir($moveTo)) |
|
221 | - return true; |
|
223 | + if (chdir($moveTo)) { |
|
224 | + return true; |
|
225 | + } |
|
222 | 226 | } |
223 | 227 | |
224 | 228 | return false; |
@@ -235,11 +239,13 @@ discard block |
||
235 | 239 | { |
236 | 240 | if (file_exists($file)) |
237 | 241 | { |
238 | - if (!$openFile = fopen($file, 'w+')) |
|
239 | - return false; |
|
242 | + if (!$openFile = fopen($file, 'w+')) { |
|
243 | + return false; |
|
244 | + } |
|
240 | 245 | |
241 | - if (fwrite($openFile, "")) |
|
242 | - return true; |
|
246 | + if (fwrite($openFile, "")) { |
|
247 | + return true; |
|
248 | + } |
|
243 | 249 | |
244 | 250 | fclose($openFile); |
245 | 251 | } |
@@ -259,12 +265,13 @@ discard block |
||
259 | 265 | { |
260 | 266 | $recursive = is_null($recursive) ? false : $recursive; |
261 | 267 | |
262 | - if (is_null($file)) |
|
263 | - throw new Exception("Missing parameter for rm!"); |
|
268 | + if (is_null($file)) { |
|
269 | + throw new Exception("Missing parameter for rm!"); |
|
270 | + } |
|
264 | 271 | |
265 | - if (file_exists($file) && !$recursive) |
|
266 | - unlink($file); |
|
267 | - elseif (is_dir($file) && $recursive) |
|
272 | + if (file_exists($file) && !$recursive) { |
|
273 | + unlink($file); |
|
274 | + } elseif (is_dir($file) && $recursive) |
|
268 | 275 | { |
269 | 276 | $that = $this; |
270 | 277 | |
@@ -293,14 +300,15 @@ discard block |
||
293 | 300 | { |
294 | 301 | $recursive = (is_null($recursive)) ? false : $recursive; |
295 | 302 | |
296 | - if (empty($file) || empty($dest)) |
|
297 | - throw new Exception("Missing parameters!"); |
|
303 | + if (empty($file) || empty($dest)) { |
|
304 | + throw new Exception("Missing parameters!"); |
|
305 | + } |
|
298 | 306 | |
299 | 307 | if (is_dir($dest)) |
300 | 308 | { |
301 | - if (!$recursive) |
|
302 | - copy($file, $dest.'/'.$file); |
|
303 | - else { |
|
309 | + if (!$recursive) { |
|
310 | + copy($file, $dest.'/'.$file); |
|
311 | + } else { |
|
304 | 312 | |
305 | 313 | $files = array(); |
306 | 314 | $files[0] = array(); |
@@ -318,20 +326,22 @@ discard block |
||
318 | 326 | |
319 | 327 | foreach ($files[1] as $item) |
320 | 328 | { |
321 | - if (!file_exists($dest.'/'.$item)) |
|
322 | - mkdir("$dest/$item", 0777, true); |
|
329 | + if (!file_exists($dest.'/'.$item)) { |
|
330 | + mkdir("$dest/$item", 0777, true); |
|
331 | + } |
|
323 | 332 | } |
324 | 333 | |
325 | 334 | foreach ($files[0] as $item) |
326 | 335 | { |
327 | - if (!file_exists("$dest/$files")) |
|
328 | - copy($item, $dest.'/'.$item); |
|
336 | + if (!file_exists("$dest/$files")) { |
|
337 | + copy($item, $dest.'/'.$item); |
|
338 | + } |
|
329 | 339 | } |
330 | 340 | }); |
331 | 341 | } |
342 | + } else { |
|
343 | + copy($file, $dest); |
|
332 | 344 | } |
333 | - else |
|
334 | - copy($file, $dest); |
|
335 | 345 | |
336 | 346 | return true; |
337 | 347 | } |
@@ -346,17 +356,21 @@ discard block |
||
346 | 356 | */ |
347 | 357 | public function mv($oldfile, $newfile) |
348 | 358 | { |
349 | - if (empty($oldfile)) |
|
350 | - throw new Exception("Missing parameter for mv!"); |
|
359 | + if (empty($oldfile)) { |
|
360 | + throw new Exception("Missing parameter for mv!"); |
|
361 | + } |
|
351 | 362 | |
352 | - if (is_dir($newfile)) |
|
353 | - $newfile .= '/'.basename($oldfile); |
|
363 | + if (is_dir($newfile)) { |
|
364 | + $newfile .= '/'.basename($oldfile); |
|
365 | + } |
|
354 | 366 | |
355 | - if ($oldfile == $newfile) |
|
356 | - throw new Exception("'$oldfile' and '$newfile' are the same file"); |
|
367 | + if ($oldfile == $newfile) { |
|
368 | + throw new Exception("'$oldfile' and '$newfile' are the same file"); |
|
369 | + } |
|
357 | 370 | |
358 | - if(!rename($oldfile, $newfile)) |
|
359 | - return false; |
|
371 | + if(!rename($oldfile, $newfile)) { |
|
372 | + return false; |
|
373 | + } |
|
360 | 374 | |
361 | 375 | return true; |
362 | 376 | } |
@@ -372,21 +386,24 @@ discard block |
||
372 | 386 | */ |
373 | 387 | public function mkdir($dir, $dest = null, $recursive = null) |
374 | 388 | { |
375 | - if (empty($dir)) |
|
376 | - throw new Exception("Missing parameter for mkdir!"); |
|
389 | + if (empty($dir)) { |
|
390 | + throw new Exception("Missing parameter for mkdir!"); |
|
391 | + } |
|
377 | 392 | |
378 | - if (empty($dest)) |
|
379 | - $dest = '.'; |
|
393 | + if (empty($dest)) { |
|
394 | + $dest = '.'; |
|
395 | + } |
|
380 | 396 | |
381 | 397 | $recursive = (is_null($recursive)) ? false : $recursive; |
382 | 398 | |
383 | - if ($recursive) |
|
384 | - mkdir("$dest/$dir", 0777, true); |
|
385 | - else { |
|
399 | + if ($recursive) { |
|
400 | + mkdir("$dest/$dir", 0777, true); |
|
401 | + } else { |
|
386 | 402 | if (!is_dir($dir)) |
387 | 403 | { |
388 | - if(!mkdir("$dir", 0777)) |
|
389 | - return false; |
|
404 | + if(!mkdir("$dir", 0777)) { |
|
405 | + return false; |
|
406 | + } |
|
390 | 407 | } |
391 | 408 | } |
392 | 409 | return true; |
@@ -401,12 +418,14 @@ discard block |
||
401 | 418 | */ |
402 | 419 | public function rmdir($dir) |
403 | 420 | { |
404 | - if (is_null($dir) || empty($dir)) |
|
405 | - throw new Exception("Missing parameter for rmdir!"); |
|
421 | + if (is_null($dir) || empty($dir)) { |
|
422 | + throw new Exception("Missing parameter for rmdir!"); |
|
423 | + } |
|
406 | 424 | |
407 | - if (rmdir($dir)) |
|
408 | - return true; |
|
409 | - else |
|
410 | - return false; |
|
425 | + if (rmdir($dir)) { |
|
426 | + return true; |
|
427 | + } else { |
|
428 | + return false; |
|
429 | + } |
|
411 | 430 | } |
412 | 431 | } |
413 | 432 | \ No newline at end of file |
@@ -74,18 +74,21 @@ discard block |
||
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 |
||
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 | /** |
@@ -31,15 +31,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -108,8 +108,9 @@ |
||
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))) |
@@ -107,11 +107,12 @@ |
||
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 |
@@ -31,15 +31,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -73,11 +73,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -209,8 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function getArrayResult() |
211 | 211 | { |
212 | - if (!empty($this->arrayResult)) |
|
213 | - return $this->arrayResult; |
|
212 | + if (!empty($this->arrayResult)) { |
|
213 | + return $this->arrayResult; |
|
214 | + } |
|
214 | 215 | |
215 | 216 | return $this->toArray(); |
216 | 217 | } |
@@ -298,8 +299,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |