Passed
Push — master ( b176c5...1503d9 )
by Darío
01:55
created
test/Db/Driver/MySQLTest.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         try
241 241
         {
242 242
             $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')";
243
-	        $result = $conn->execute($sql);
243
+            $result = $conn->execute($sql);
244 244
         }
245 245
         catch (\Exception $e)
246 246
         {
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 
512 512
         try
513 513
         {
514
-	        $sql = "INSERT INTO MYTABLE (DESCRIPTION) VALUES ('TRANS_SHORTCUT_1')";
515
-	        $result = $conn->execute($sql);
514
+            $sql = "INSERT INTO MYTABLE (DESCRIPTION) VALUES ('TRANS_SHORTCUT_1')";
515
+            $result = $conn->execute($sql);
516 516
 
517
-	        $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')";
518
-	        $result = $conn->execute($sql);
517
+            $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')";
518
+            $result = $conn->execute($sql);
519 519
         }
520 520
         catch (InvalidQueryException $e)
521 521
         {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public function testCannotStablishConnection()
146 146
     {
147 147
         $options = $this->options;
148
-        $options["dbhost"] = 'myserver';   // this server does not exists
148
+        $options["dbhost"] = 'myserver'; // this server does not exists
149 149
 
150 150
         $conn = new MySQL($options);
151 151
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         $this->assertEquals(2, $conn->getNumFields());
273 273
         $this->assertEquals(0, $conn->getRowsAffected());
274 274
 
275
-        $rowset = $conn->getArrayResult();    # array with results
275
+        $rowset = $conn->getArrayResult(); # array with results
276 276
         $row = array_shift($rowset);
277 277
 
278 278
         $this->assertArrayHasKey("ID", $row);
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
         $result = $conn->execute($sql);
300 300
         $rowcount = count($conn->getArrayResult());
301 301
 
302
-        $this->assertTrue(($rowcount === 1));    # the row is available for now
302
+        $this->assertTrue(($rowcount === 1)); # the row is available for now
303 303
 
304 304
         # properties modified by execute() method
305 305
         $this->assertEquals(1, $conn->getNumRows());
306 306
         $this->assertEquals(2, $conn->getNumFields());
307
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
307
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
308 308
 
309 309
         $this->assertTrue($conn->commit());
310 310
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $result = $conn->execute($sql);
314 314
         $rowcount = count($conn->getArrayResult());
315 315
 
316
-        $this->assertTrue(($rowcount === 1));    # the row is available
316
+        $this->assertTrue(($rowcount === 1)); # the row is available
317 317
     }
318 318
 
319 319
     /**
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
         $result = $conn->execute($sql);
337 337
         $rowcount = count($conn->getArrayResult());
338 338
 
339
-        $this->assertTrue(($rowcount === 1));    # the row is available for now
339
+        $this->assertTrue(($rowcount === 1)); # the row is available for now
340 340
 
341 341
         # properties modified by execute() method
342 342
         $this->assertEquals(1, $conn->getNumRows());
343 343
         $this->assertEquals(2, $conn->getNumFields());
344
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
344
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
345 345
 
346 346
         $this->assertTrue($conn->rollback());
347 347
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         $result = $conn->execute($sql);
351 351
         $rowcount = count($conn->getArrayResult());
352 352
 
353
-        $this->assertNotTrue(($rowcount === 1));    # the row is not available
353
+        $this->assertNotTrue(($rowcount === 1)); # the row is not available
354 354
     }
355 355
 
356 356
     /**
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
         $result = $conn->execute($sql);
383 383
         $rowcount = count($conn->getArrayResult());
384 384
 
385
-        $this->assertTrue(($rowcount === 4));    # the rows are available for now
385
+        $this->assertTrue(($rowcount === 4)); # the rows are available for now
386 386
 
387 387
         # properties modified by execute() method
388 388
         $this->assertEquals(4, $conn->getNumRows());
389 389
         $this->assertEquals(2, $conn->getNumFields());
390
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
390
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
391 391
 
392 392
         $this->assertTrue($conn->commit());
393 393
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
         $result = $conn->execute($sql);
397 397
         $rowcount = count($conn->getArrayResult());
398 398
 
399
-        $this->assertTrue(($rowcount === 4));    # the row is available
399
+        $this->assertTrue(($rowcount === 4)); # the row is available
400 400
     }
401 401
 
402 402
     /**
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
         $result = $conn->execute($sql);
429 429
         $rowcount = count($conn->getArrayResult());
430 430
 
431
-        $this->assertTrue(($rowcount === 4));    # the rows are available for now
431
+        $this->assertTrue(($rowcount === 4)); # the rows are available for now
432 432
 
433 433
         # properties modified by execute() method
434 434
         $this->assertEquals(4, $conn->getNumRows());
435 435
         $this->assertEquals(2, $conn->getNumFields());
436
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
436
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
437 437
 
438 438
         $this->assertTrue($conn->rollback());
439 439
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $result = $conn->execute($sql);
443 443
         $rowcount = count($conn->getArrayResult());
444 444
 
445
-        $this->assertNotTrue(($rowcount === 4));    # the row is available
445
+        $this->assertNotTrue(($rowcount === 4)); # the row is available
446 446
     }
447 447
 
448 448
     /**
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
         $result = $conn->execute($sql);
474 474
         $rowcount = count($conn->getArrayResult());
475 475
 
476
-        $this->assertTrue(($rowcount === 2));    # the rows are available for now
476
+        $this->assertTrue(($rowcount === 2)); # the rows are available for now
477 477
 
478 478
         # properties modified by execute() method
479 479
         $this->assertEquals(2, $conn->getNumRows());
480 480
         $this->assertEquals(2, $conn->getNumFields());
481
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
481
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
482 482
 
483 483
         # ends the transaction
484 484
         $conn->endTransaction();
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         $result = $conn->execute($sql);
489 489
         $rowcount = count($conn->getArrayResult());
490 490
 
491
-        $this->assertTrue(($rowcount === 2));    # the row is available
491
+        $this->assertTrue(($rowcount === 2)); # the row is available
492 492
     }
493 493
 
494 494
     /**
@@ -532,6 +532,6 @@  discard block
 block discarded – undo
532 532
         $result = $conn->execute($sql);
533 533
         $rowcount = count($conn->getArrayResult());
534 534
 
535
-        $this->assertNotTrue(($rowcount === 0));    # the rows are not available
535
+        $this->assertNotTrue(($rowcount === 0)); # the rows are not available
536 536
     }
537 537
 }
538 538
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -84,12 +84,10 @@  discard block
 block discarded – undo
84 84
 
85 85
         try {
86 86
             $conn->disconnect();
87
-        }
88
-        catch (\Exception $e)
87
+        } catch (\Exception $e)
89 88
         {
90 89
             $errorObject = ($e instanceof \LogicException);
91
-        }
92
-        finally
90
+        } finally
93 91
         {
94 92
             $this->assertNotTrue($conn->isConnected());
95 93
             $this->assertTrue($errorObject, $e->getMessage());
@@ -125,12 +123,10 @@  discard block
 block discarded – undo
125 123
 
126 124
         try {
127 125
             $conn->reconnect();
128
-        }
129
-        catch (\Exception $e)
126
+        } catch (\Exception $e)
130 127
         {
131 128
             $errorObject = ($e instanceof \LogicException);
132
-        }
133
-        finally
129
+        } finally
134 130
         {
135 131
             $this->assertTrue($errorObject, $e->getMessage());
136 132
             $this->assertNotTrue($conn->isConnected());
@@ -155,13 +151,11 @@  discard block
 block discarded – undo
155 151
 
156 152
         try {
157 153
             $mysqliObject = $conn->connect();
158
-        }
159
-        catch (\Exception $e)
154
+        } catch (\Exception $e)
160 155
         {
161 156
             $errorObject = ($e instanceof ConnectionException);
162 157
             $message = $e->getMessage();
163
-        }
164
-        finally
158
+        } finally
165 159
         {
166 160
             $this->assertTrue($errorObject, $message);
167 161
             $this->assertNotTrue($conn->isConnected());
@@ -241,13 +235,11 @@  discard block
 block discarded – undo
241 235
         {
242 236
             $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')";
243 237
 	        $result = $conn->execute($sql);
244
-        }
245
-        catch (\Exception $e)
238
+        } catch (\Exception $e)
246 239
         {
247 240
             $errorObject = ($e instanceof InvalidQueryException);
248 241
             $message = $e->getMessage();
249
-        }
250
-        finally
242
+        } finally
251 243
         {
252 244
             $this->assertTrue($errorObject, $message);
253 245
         }
@@ -516,8 +508,7 @@  discard block
 block discarded – undo
516 508
 
517 509
 	        $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')";
518 510
 	        $result = $conn->execute($sql);
519
-        }
520
-        catch (InvalidQueryException $e)
511
+        } catch (InvalidQueryException $e)
521 512
         {
522 513
             $message = $e->getMessage();
523 514
             #·not necessary!
Please login to merge, or discard this patch.
test/FileSystem/ShellTest.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -171,5 +171,5 @@
 block discarded – undo
171 171
             'foo2', // directory
172 172
             'foo4', // not a directory or file
173 173
         true);
174
-   }
174
+    }
175 175
 }
176 176
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -141,13 +141,11 @@
 block discarded – undo
141 141
         try
142 142
         {
143 143
             $shell->cp('foo2', 'foo3');
144
-        }
145
-        catch (\Exception $e)
144
+        } catch (\Exception $e)
146 145
         {
147 146
             # omitting directory
148 147
             $errorObject = ($e instanceof \RuntimeException);
149
-        }
150
-        finally
148
+        } finally
151 149
         {
152 150
             $this->assertTrue($errorObject, $e->getMessage());
153 151
         }
Please login to merge, or discard this patch.
src/Db/Driver/MySQL.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             {
119 119
                 if (is_string($param_values[$i]))
120 120
                     $bind_types .= 's';
121
-                else if(is_float($param_values[$i]))
121
+                else if (is_float($param_values[$i]))
122 122
                     $bind_types .= 'd';
123 123
                 # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?)
124 124
                 else
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             $this->numFields = $this->dbconn->field_count;
179 179
 
180 180
         if ($this->transac_mode)
181
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
181
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
182 182
 
183 183
         /*
184 184
          * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries,
Please login to merge, or discard this patch.
Braces   +45 added lines, -36 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"] = "utf8";
34
+        if (!array_key_exists("dbchar", $options)) {
35
+                    $options["dbchar"] = "utf8";
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,13 +54,15 @@  discard block
 block discarded – undo
52 54
      */
53 55
     public function connect()
54 56
     {
55
-        if (!extension_loaded('mysqli'))
56
-            throw new \RuntimeException("The Mysqli extension is not loaded");
57
+        if (!extension_loaded('mysqli')) {
58
+                    throw new \RuntimeException("The Mysqli extension is not loaded");
59
+        }
57 60
 
58
-        if (!is_null($this->dbport) && !empty($this->dbport))
59
-            $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport);
60
-        else
61
-            $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
61
+        if (!is_null($this->dbport) && !empty($this->dbport)) {
62
+                    $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport);
63
+        } else {
64
+                    $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
65
+        }
62 66
 
63 67
         if ($conn->connect_errno)
64 68
         {
@@ -68,8 +72,7 @@  discard block
 block discarded – undo
68 72
              * the warning message "Property access is not allowed yet".
69 73
              */
70 74
             throw new Exception\ConnectionException(mysqli_connect_error(), mysqli_connect_errno());
71
-        }
72
-        else
75
+        } else
73 76
         {
74 77
             $this->dbconn = $conn;
75 78
             $this->dbconn->set_charset($this->dbchar);
@@ -116,13 +119,15 @@  discard block
 block discarded – undo
116 119
 
117 120
             for ($i = 0; $i < $n_params; $i++)
118 121
             {
119
-                if (is_string($param_values[$i]))
120
-                    $bind_types .= 's';
121
-                else if(is_float($param_values[$i]))
122
-                    $bind_types .= 'd';
122
+                if (is_string($param_values[$i])) {
123
+                                    $bind_types .= 's';
124
+                } else if(is_float($param_values[$i])) {
125
+                                    $bind_types .= 'd';
126
+                }
123 127
                 # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?)
124
-                else
125
-                    $bind_types .= 's';
128
+                else {
129
+                                    $bind_types .= 's';
130
+                }
126 131
 
127 132
                 $bind_values[] = '$param_values[' . $i . ']';
128 133
             }
@@ -143,12 +148,12 @@  discard block
 block discarded – undo
143 148
                      * It is useful to prevent rollback transactions on insert statements because
144 149
                      * insert statement do not free results.
145 150
                      */
146
-                    if ($res)
147
-                        $this->result = $res;
151
+                    if ($res) {
152
+                                            $this->result = $res;
153
+                    }
148 154
                 }
149 155
             }
150
-        }
151
-        else
156
+        } else
152 157
         {
153 158
             $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL);
154 159
 
@@ -165,20 +170,23 @@  discard block
 block discarded – undo
165 170
         }
166 171
 
167 172
         # identify SELECT, SHOW, DESCRIBE or EXPLAIN queries
168
-        if (is_object($this->result) && property_exists($this->result, 'num_rows'))
169
-            $this->numRows = $this->result->num_rows;
170
-        else
173
+        if (is_object($this->result) && property_exists($this->result, 'num_rows')) {
174
+                    $this->numRows = $this->result->num_rows;
175
+        } else
171 176
         {
172 177
             # affected_rows return the same of num_rows on select statements!
173
-            if (property_exists($this->dbconn, 'affected_rows'))
174
-                $this->rowsAffected = $this->dbconn->affected_rows;
178
+            if (property_exists($this->dbconn, 'affected_rows')) {
179
+                            $this->rowsAffected = $this->dbconn->affected_rows;
180
+            }
175 181
         }
176 182
 
177
-        if (property_exists($this->dbconn, 'field_count'))
178
-            $this->numFields = $this->dbconn->field_count;
183
+        if (property_exists($this->dbconn, 'field_count')) {
184
+                    $this->numFields = $this->dbconn->field_count;
185
+        }
179 186
 
180
-        if ($this->transac_mode)
181
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
187
+        if ($this->transac_mode) {
188
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
189
+        }
182 190
 
183 191
         /*
184 192
          * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries,
@@ -247,9 +255,8 @@  discard block
 block discarded – undo
247 255
             {
248 256
                 $data[] = $row;
249 257
             }
250
-        }
251
-        else
252
-            /*
258
+        } else {
259
+                    /*
253 260
              * "This kind of exception should lead directly to a fix in your code"
254 261
              * So much production tests tell us this error is throwed because developers
255 262
              * execute toArray() before execute().
@@ -257,6 +264,7 @@  discard block
 block discarded – undo
257 264
              * Ref: http://php.net/manual/en/class.logicexception.php
258 265
              */
259 266
             throw new \LogicException('There are not data in the buffer!');
267
+        }
260 268
 
261 269
         $this->arrayResult = $data;
262 270
 
@@ -271,7 +279,8 @@  discard block
 block discarded – undo
271 279
     public function __destruct()
272 280
     {
273 281
         # prevent "Property access is not allowed yet" with @ on failure connections
274
-        if ($this->dbconn !== false && !is_null($this->dbconn))
275
-            @$this->dbconn->close();
282
+        if ($this->dbconn !== false && !is_null($this->dbconn)) {
283
+                    @$this->dbconn->close();
284
+        }
276 285
     }
277 286
 }
278 287
\ No newline at end of file
Please login to merge, or discard this patch.
src/FileSystem/Shell.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -95,19 +95,19 @@  discard block
 block discarded – undo
95 95
             {
96 96
                 foreach ($contents as $i)
97 97
                 {
98
-                    if (is_file($directory.'/'.$i))
98
+                    if (is_file($directory . '/' . $i))
99 99
                     {
100
-                        $allContents[] = ($showParentPath) ? $directory.'/'.$i : $i;
100
+                        $allContents[] = ($showParentPath) ? $directory . '/' . $i : $i;
101 101
 
102
-                        $this->buffer = $directory.'/'.$i;
102
+                        $this->buffer = $directory . '/' . $i;
103 103
                         call_user_func($fileCallback, $this);
104 104
                     }
105
-                    else if (is_dir($directory.'/'.$i))
105
+                    else if (is_dir($directory . '/' . $i))
106 106
                     {
107
-                        $allContents[] = ($showParentPath) ? $directory.'/'.$i : $i;
108
-                        $allContents[] = $this->getContents($directory.'/'.$i, $fileCallback, $dirCallback, null, false);
107
+                        $allContents[] = ($showParentPath) ? $directory . '/' . $i : $i;
108
+                        $allContents[] = $this->getContents($directory . '/' . $i, $fileCallback, $dirCallback, null, false);
109 109
 
110
-                        $this->buffer = $directory.'/'.$i;
110
+                        $this->buffer = $directory . '/' . $i;
111 111
                         call_user_func($dirCallback, $this);
112 112
                     }
113 113
                 }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                 if (!empty($path))
203 203
                     if (!strlen(stristr($item, $path)) > 0)
204 204
                         continue;
205
-                if (strstr($item,'~') === false && $item != '.' && $item != '..')
205
+                if (strstr($item, '~') === false && $item != '.' && $item != '..')
206 206
                     $filesToReturn[] = $item;
207 207
             }
208 208
         }
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
                     {
340 340
                         foreach ($files["folders"] as $folder)
341 341
                         {
342
-                            if (!file_exists($dest.'/'.$folder))
342
+                            if (!file_exists($dest . '/' . $folder))
343 343
                                 mkdir("$dest/$folder", 0777, true);
344 344
                         }
345 345
                     }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                         foreach ($files["files"] as $item)
350 350
                         {
351 351
                             if (!file_exists("$dest/$files"))
352
-                                copy($item, $dest.'/'.$item);
352
+                                copy($item, $dest . '/' . $item);
353 353
                         }
354 354
                     }
355 355
                 }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
         if (is_dir($dest))
360 360
         {
361 361
             if (!$recursive)
362
-                copy($file, $dest.'/'.$file);
362
+                copy($file, $dest . '/' . $file);
363 363
             else {
364 364
 
365 365
                 $files = array();
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
 
379 379
                     foreach ($files[1] as $item)
380 380
                     {
381
-                        if (!file_exists($dest.'/'.$item))
381
+                        if (!file_exists($dest . '/' . $item))
382 382
                             mkdir("$dest/$item", 0777, true);
383 383
                     }
384 384
 
385 385
                     foreach ($files[0] as $item)
386 386
                     {
387 387
                         if (!file_exists("$dest/$files"))
388
-                            copy($item, $dest.'/'.$item);
388
+                            copy($item, $dest . '/' . $item);
389 389
                     }
390 390
                 });
391 391
             }
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
             throw new \InvalidArgumentException("Missing first parameter");
411 411
 
412 412
         if (is_dir($newfile))
413
-                $newfile .= '/'.basename($oldfile);
413
+                $newfile .= '/' . basename($oldfile);
414 414
 
415 415
         if ($oldfile == $newfile)
416 416
             throw new \Exception("'$oldfile' and '$newfile' are the same file");
417 417
 
418
-        if(!rename($oldfile, $newfile))
418
+        if (!rename($oldfile, $newfile))
419 419
             return false;
420 420
 
421 421
         return true;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         else {
446 446
             if (!is_dir($dir))
447 447
             {
448
-                if(!mkdir("$dir", 0777))
448
+                if (!mkdir("$dir", 0777))
449 449
                     return false;
450 450
             }
451 451
         }
Please login to merge, or discard this patch.
Braces   +100 added lines, -78 removed lines patch added patch discarded remove patch
@@ -85,8 +85,9 @@  discard block
 block discarded – undo
85 85
         {
86 86
             foreach ($this->ls($directory) as $item)
87 87
             {
88
-                if ($item != '.' && $item != '..')
89
-                    $contents[] = $item;
88
+                if ($item != '.' && $item != '..') {
89
+                                    $contents[] = $item;
90
+                }
90 91
             }
91 92
 
92 93
             //$allContents = $contents;
@@ -101,8 +102,7 @@  discard block
 block discarded – undo
101 102
 
102 103
                         $this->buffer = $directory.'/'.$i;
103 104
                         call_user_func($fileCallback, $this);
104
-                    }
105
-                    else if (is_dir($directory.'/'.$i))
105
+                    } else if (is_dir($directory.'/'.$i))
106 106
                     {
107 107
                         $allContents[] = ($showParentPath) ? $directory.'/'.$i : $i;
108 108
                         $allContents[] = $this->getContents($directory.'/'.$i, $fileCallback, $dirCallback, null, false);
@@ -112,14 +112,15 @@  discard block
 block discarded – undo
112 112
                     }
113 113
                 }
114 114
             }
115
+        } else if (is_file($directory)) {
116
+                    throw new \InvalidArgumentException("'$directory' is actually a file");
117
+        } else {
118
+                    throw new \InvalidArgumentException("The directory '$directory' does not exists");
115 119
         }
116
-        else if (is_file($directory))
117
-            throw new \InvalidArgumentException("'$directory' is actually a file");
118
-        else
119
-            throw new \InvalidArgumentException("The directory '$directory' does not exists");
120 120
 
121
-        if (!is_null($callback))
122
-            call_user_func($callback, $this);
121
+        if (!is_null($callback)) {
122
+                    call_user_func($callback, $this);
123
+        }
123 124
 
124 125
         return $allContents;
125 126
     }
@@ -131,10 +132,11 @@  discard block
 block discarded – undo
131 132
      */
132 133
     public function pwd()
133 134
     {
134
-        if (getcwd())
135
-            $this->buffer = getcwd();
136
-        else
137
-            return false;
135
+        if (getcwd()) {
136
+                    $this->buffer = getcwd();
137
+        } else {
138
+                    return false;
139
+        }
138 140
 
139 141
         return $this->buffer;
140 142
     }
@@ -153,9 +155,9 @@  discard block
 block discarded – undo
153 155
 
154 156
         $path = (is_null($path) || empty($path)) ? '.' : $path;
155 157
 
156
-        if (is_file($path))
157
-            $filesToReturn = array($path);
158
-        else if (is_dir($path))
158
+        if (is_file($path)) {
159
+                    $filesToReturn = array($path);
160
+        } else if (is_dir($path))
159 161
         {
160 162
             $pathIns = dir($path);
161 163
 
@@ -181,29 +183,30 @@  discard block
 block discarded – undo
181 183
 
182 184
                 foreach ($files as $item)
183 185
                     $filesToReturn[] = $item;*/
184
-            }
185
-            else
186
+            } else
186 187
             {
187 188
                 while (($item = $pathIns->read()) !== false)
188 189
                 {
189
-                    if ($item != '.' && $item != '..')
190
-                        $filesToReturn[] = $item;
190
+                    if ($item != '.' && $item != '..') {
191
+                                            $filesToReturn[] = $item;
192
+                    }
191 193
                 }
192 194
 
193 195
                 $pathIns->close();
194 196
             }
195
-        }
196
-        else {
197
+        } else {
197 198
 
198 199
             $contents = $this->ls();
199 200
 
200 201
             foreach ($contents as $item)
201 202
             {
202
-                if (!empty($path))
203
-                    if (!strlen(stristr($item, $path)) > 0)
203
+                if (!empty($path)) {
204
+                                    if (!strlen(stristr($item, $path)) > 0)
204 205
                         continue;
205
-                if (strstr($item,'~') === false && $item != '.' && $item != '..')
206
-                    $filesToReturn[] = $item;
206
+                }
207
+                if (strstr($item,'~') === false && $item != '.' && $item != '..') {
208
+                                    $filesToReturn[] = $item;
209
+                }
207 210
             }
208 211
         }
209 212
 
@@ -223,8 +226,9 @@  discard block
 block discarded – undo
223 226
 
224 227
         if (is_dir($path))
225 228
         {
226
-            if (chdir($path))
227
-                return true;
229
+            if (chdir($path)) {
230
+                            return true;
231
+            }
228 232
         }
229 233
 
230 234
         return false;
@@ -266,12 +270,13 @@  discard block
 block discarded – undo
266 270
     {
267 271
         $recursive = is_null($recursive) ? false : $recursive;
268 272
 
269
-        if (is_null($file))
270
-            throw new \InvalidArgumentException("Missing first parameter");
273
+        if (is_null($file)) {
274
+                    throw new \InvalidArgumentException("Missing first parameter");
275
+        }
271 276
 
272
-        if (file_exists($file) && !$recursive)
273
-            unlink($file);
274
-        elseif (is_dir($file) && $recursive)
277
+        if (file_exists($file) && !$recursive) {
278
+                    unlink($file);
279
+        } elseif (is_dir($file) && $recursive)
275 280
         {
276 281
             $that = $this;
277 282
 
@@ -300,11 +305,13 @@  discard block
 block discarded – undo
300 305
     {
301 306
         $recursive = (is_null($recursive)) ? false : $recursive;
302 307
 
303
-        if (empty($file) || empty($dest))
304
-            throw new \InvalidArgumentException("Missing parameters");
308
+        if (empty($file) || empty($dest)) {
309
+                    throw new \InvalidArgumentException("Missing parameters");
310
+        }
305 311
 
306
-        if (is_dir($file) && !$recursive)
307
-            throw new \RuntimeException("Ommiting directory <<$foo>>");
312
+        if (is_dir($file) && !$recursive) {
313
+                    throw new \RuntimeException("Ommiting directory <<$foo>>");
314
+        }
308 315
 
309 316
         if (is_dir($file) && (is_dir($dest) || !file_exists($dest)))
310 317
         {
@@ -313,11 +320,13 @@  discard block
 block discarded – undo
313 320
                 "folders" => []
314 321
             ];
315 322
 
316
-            if (is_dir($dest))
317
-                $files["folders"][] = basename($file);
323
+            if (is_dir($dest)) {
324
+                            $files["folders"][] = basename($file);
325
+            }
318 326
 
319
-            if (!file_exists($dest))
320
-                mkdir($dest);
327
+            if (!file_exists($dest)) {
328
+                            mkdir($dest);
329
+            }
321 330
 
322 331
             $that = $this;
323 332
 
@@ -339,8 +348,9 @@  discard block
 block discarded – undo
339 348
                     {
340 349
                         foreach ($files["folders"] as $folder)
341 350
                         {
342
-                            if (!file_exists($dest.'/'.$folder))
343
-                                mkdir("$dest/$folder", 0777, true);
351
+                            if (!file_exists($dest.'/'.$folder)) {
352
+                                                            mkdir("$dest/$folder", 0777, true);
353
+                            }
344 354
                         }
345 355
                     }
346 356
 
@@ -348,8 +358,9 @@  discard block
 block discarded – undo
348 358
                     {
349 359
                         foreach ($files["files"] as $item)
350 360
                         {
351
-                            if (!file_exists("$dest/$files"))
352
-                                copy($item, $dest.'/'.$item);
361
+                            if (!file_exists("$dest/$files")) {
362
+                                                            copy($item, $dest.'/'.$item);
363
+                            }
353 364
                         }
354 365
                     }
355 366
                 }
@@ -358,9 +369,9 @@  discard block
 block discarded – undo
358 369
 
359 370
         if (is_dir($dest))
360 371
         {
361
-            if (!$recursive)
362
-                copy($file, $dest.'/'.$file);
363
-            else {
372
+            if (!$recursive) {
373
+                            copy($file, $dest.'/'.$file);
374
+            } else {
364 375
 
365 376
                 $files = array();
366 377
                 $files[0] = array();
@@ -378,20 +389,22 @@  discard block
 block discarded – undo
378 389
 
379 390
                     foreach ($files[1] as $item)
380 391
                     {
381
-                        if (!file_exists($dest.'/'.$item))
382
-                            mkdir("$dest/$item", 0777, true);
392
+                        if (!file_exists($dest.'/'.$item)) {
393
+                                                    mkdir("$dest/$item", 0777, true);
394
+                        }
383 395
                     }
384 396
 
385 397
                     foreach ($files[0] as $item)
386 398
                     {
387
-                        if (!file_exists("$dest/$files"))
388
-                            copy($item, $dest.'/'.$item);
399
+                        if (!file_exists("$dest/$files")) {
400
+                                                    copy($item, $dest.'/'.$item);
401
+                        }
389 402
                     }
390 403
                 });
391 404
             }
405
+        } else {
406
+                    copy($file, $dest);
392 407
         }
393
-        else
394
-            copy($file, $dest);
395 408
 
396 409
         return true;
397 410
     }
@@ -406,17 +419,21 @@  discard block
 block discarded – undo
406 419
      */
407 420
     public function mv($oldfile, $newfile)
408 421
     {
409
-        if (empty($oldfile))
410
-            throw new \InvalidArgumentException("Missing first parameter");
422
+        if (empty($oldfile)) {
423
+                    throw new \InvalidArgumentException("Missing first parameter");
424
+        }
411 425
 
412
-        if (is_dir($newfile))
413
-                $newfile .= '/'.basename($oldfile);
426
+        if (is_dir($newfile)) {
427
+                        $newfile .= '/'.basename($oldfile);
428
+        }
414 429
 
415
-        if ($oldfile == $newfile)
416
-            throw new \Exception("'$oldfile' and '$newfile' are the same file");
430
+        if ($oldfile == $newfile) {
431
+                    throw new \Exception("'$oldfile' and '$newfile' are the same file");
432
+        }
417 433
 
418
-        if(!rename($oldfile, $newfile))
419
-            return false;
434
+        if(!rename($oldfile, $newfile)) {
435
+                    return false;
436
+        }
420 437
 
421 438
         return true;
422 439
     }
@@ -432,21 +449,24 @@  discard block
 block discarded – undo
432 449
      */
433 450
     public function mkdir($dir, $dest = null, $recursive = null)
434 451
     {
435
-        if (empty($dir))
436
-            throw new \InvalidArgumentException("Missing first parameter");
452
+        if (empty($dir)) {
453
+                    throw new \InvalidArgumentException("Missing first parameter");
454
+        }
437 455
 
438
-        if (empty($dest))
439
-            $dest = '.';
456
+        if (empty($dest)) {
457
+                    $dest = '.';
458
+        }
440 459
 
441 460
         $recursive = (is_null($recursive)) ? false : $recursive;
442 461
 
443
-        if ($recursive)
444
-            mkdir("$dest/$dir", 0777, true);
445
-        else {
462
+        if ($recursive) {
463
+                    mkdir("$dest/$dir", 0777, true);
464
+        } else {
446 465
             if (!is_dir($dir))
447 466
             {
448
-                if(!mkdir("$dir", 0777))
449
-                    return false;
467
+                if(!mkdir("$dir", 0777)) {
468
+                                    return false;
469
+                }
450 470
             }
451 471
         }
452 472
         return true;
@@ -461,12 +481,14 @@  discard block
 block discarded – undo
461 481
      */
462 482
     public function rmdir($dir)
463 483
     {
464
-        if (is_null($dir) || empty($dir))
465
-            throw new \RuntimeException("Missing first parameter");
484
+        if (is_null($dir) || empty($dir)) {
485
+                    throw new \RuntimeException("Missing first parameter");
486
+        }
466 487
 
467
-        if (rmdir($dir))
468
-            return true;
469
-        else
470
-            return false;
488
+        if (rmdir($dir)) {
489
+                    return true;
490
+        } else {
491
+                    return false;
492
+        }
471 493
     }
472 494
 }
473 495
\ No newline at end of file
Please login to merge, or discard this patch.