Passed
Push — master ( c7da61...4151d4 )
by Darío
01:46
created
test/Db/Driver/MySQLTest.php 2 patches
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -83,12 +83,10 @@  discard block
 block discarded – undo
83 83
 
84 84
         try {
85 85
             $conn->disconnect();
86
-        }
87
-        catch (\Exception $e)
86
+        } catch (\Exception $e)
88 87
         {
89 88
             $errorObject = ($e instanceof \LogicException);
90
-        }
91
-        finally
89
+        } finally
92 90
         {
93 91
             $this->assertNotTrue($conn->isConnected());
94 92
             $this->assertTrue($errorObject, $e->getMessage());
@@ -124,12 +122,10 @@  discard block
 block discarded – undo
124 122
 
125 123
         try {
126 124
             $conn->reconnect();
127
-        }
128
-        catch (\Exception $e)
125
+        } catch (\Exception $e)
129 126
         {
130 127
             $errorObject = ($e instanceof \LogicException);
131
-        }
132
-        finally
128
+        } finally
133 129
         {
134 130
             $this->assertTrue($errorObject, $e->getMessage());
135 131
             $this->assertNotTrue($conn->isConnected());
@@ -154,13 +150,11 @@  discard block
 block discarded – undo
154 150
 
155 151
         try {
156 152
             $mysqliObject = $conn->connect();
157
-        }
158
-        catch (\Exception $e)
153
+        } catch (\Exception $e)
159 154
         {
160 155
             $errorObject = ($e instanceof ConnectionException);
161 156
             $message = $e->getMessage();
162
-        }
163
-        finally
157
+        } finally
164 158
         {
165 159
             $this->assertTrue($errorObject, $message);
166 160
             $this->assertNotTrue($conn->isConnected());
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function testCannotStablishConnection()
145 145
     {
146 146
         $options = $this->options;
147
-        $options["dbhost"] = 'myserver';   // this server does not exists
147
+        $options["dbhost"] = 'myserver'; // this server does not exists
148 148
 
149 149
         $conn = new MySQL($options);
150 150
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         $this->assertEquals(2, $conn->getNumFields());
241 241
         $this->assertEquals(0, $conn->getRowsAffected());
242 242
 
243
-        $rowset = $conn->getArrayResult();    # array with results
243
+        $rowset = $conn->getArrayResult(); # array with results
244 244
         $row = array_shift($rowset);
245 245
 
246 246
         $this->assertArrayHasKey("ID", $row);
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         $result = $conn->execute($sql);
268 268
         $rowcount = count($conn->getArrayResult());
269 269
 
270
-        $this->assertTrue(($rowcount === 1));    # the row is available for now
270
+        $this->assertTrue(($rowcount === 1)); # the row is available for now
271 271
 
272 272
         # properties modified by execute() method
273 273
         $this->assertEquals(1, $conn->getNumRows());
274 274
         $this->assertEquals(2, $conn->getNumFields());
275
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
275
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
276 276
 
277 277
         $this->assertTrue($conn->commit());
278 278
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $result = $conn->execute($sql);
282 282
         $rowcount = count($conn->getArrayResult());
283 283
 
284
-        $this->assertTrue(($rowcount === 1));    # the row is available
284
+        $this->assertTrue(($rowcount === 1)); # the row is available
285 285
     }
286 286
 
287 287
     /**
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
         $result = $conn->execute($sql);
305 305
         $rowcount = count($conn->getArrayResult());
306 306
 
307
-        $this->assertTrue(($rowcount === 1));    # the row is available for now
307
+        $this->assertTrue(($rowcount === 1)); # the row is available for now
308 308
 
309 309
         # properties modified by execute() method
310 310
         $this->assertEquals(1, $conn->getNumRows());
311 311
         $this->assertEquals(2, $conn->getNumFields());
312
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
312
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
313 313
 
314 314
         $this->assertTrue($conn->rollback());
315 315
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
         $result = $conn->execute($sql);
319 319
         $rowcount = count($conn->getArrayResult());
320 320
 
321
-        $this->assertNotTrue(($rowcount === 1));    # the row is not available
321
+        $this->assertNotTrue(($rowcount === 1)); # the row is not available
322 322
     }
323 323
 
324 324
     /**
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
         $result = $conn->execute($sql);
351 351
         $rowcount = count($conn->getArrayResult());
352 352
 
353
-        $this->assertTrue(($rowcount === 4));    # the rows are available for now
353
+        $this->assertTrue(($rowcount === 4)); # the rows are available for now
354 354
 
355 355
         # properties modified by execute() method
356 356
         $this->assertEquals(4, $conn->getNumRows());
357 357
         $this->assertEquals(2, $conn->getNumFields());
358
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
358
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
359 359
 
360 360
         $this->assertTrue($conn->commit());
361 361
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         $result = $conn->execute($sql);
365 365
         $rowcount = count($conn->getArrayResult());
366 366
 
367
-        $this->assertTrue(($rowcount === 4));    # the row is available
367
+        $this->assertTrue(($rowcount === 4)); # the row is available
368 368
     }
369 369
 
370 370
     /**
@@ -396,12 +396,12 @@  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 rows are available for now
399
+        $this->assertTrue(($rowcount === 4)); # the rows are available for now
400 400
 
401 401
         # properties modified by execute() method
402 402
         $this->assertEquals(4, $conn->getNumRows());
403 403
         $this->assertEquals(2, $conn->getNumFields());
404
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
404
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
405 405
 
406 406
         $this->assertTrue($conn->rollback());
407 407
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
         $result = $conn->execute($sql);
411 411
         $rowcount = count($conn->getArrayResult());
412 412
 
413
-        $this->assertNotTrue(($rowcount === 4));    # the row is available
413
+        $this->assertNotTrue(($rowcount === 4)); # the row is available
414 414
     }
415 415
 
416 416
     /**
@@ -441,12 +441,12 @@  discard block
 block discarded – undo
441 441
         $result = $conn->execute($sql);
442 442
         $rowcount = count($conn->getArrayResult());
443 443
 
444
-        $this->assertTrue(($rowcount === 2));    # the rows are available for now
444
+        $this->assertTrue(($rowcount === 2)); # the rows are available for now
445 445
 
446 446
         # properties modified by execute() method
447 447
         $this->assertEquals(2, $conn->getNumRows());
448 448
         $this->assertEquals(2, $conn->getNumFields());
449
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
449
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
450 450
 
451 451
         # ends the transaction
452 452
         $conn->endTransaction();
@@ -456,6 +456,6 @@  discard block
 block discarded – undo
456 456
         $result = $conn->execute($sql);
457 457
         $rowcount = count($conn->getArrayResult());
458 458
 
459
-        $this->assertTrue(($rowcount === 2));    # the row is available
459
+        $this->assertTrue(($rowcount === 2)); # the row is available
460 460
     }
461 461
 }
462 462
\ No newline at end of file
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, * and TRUE for other successful queries, it should be handled to return only objects or resources.
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, * and TRUE for other successful queries, it should be handled to return only objects or resources.
@@ -255,9 +263,8 @@  discard block
 block discarded – undo
255 263
             {
256 264
                 $data[] = $row;
257 265
             }
258
-        }
259
-        else
260
-            /*
266
+        } else {
267
+                    /*
261 268
              * "This kind of exception should lead directly to a fix in your code"
262 269
              * So much production tests tell us this error is throwed because developers
263 270
              * execute toArray() before execute().
@@ -265,6 +272,7 @@  discard block
 block discarded – undo
265 272
              * Ref: http://php.net/manual/en/class.logicexception.php
266 273
              */
267 274
             throw new \LogicException('There are not data in the buffer!');
275
+        }
268 276
 
269 277
         $this->arrayResult = $data;
270 278
 
@@ -279,7 +287,8 @@  discard block
 block discarded – undo
279 287
     public function __destruct()
280 288
     {
281 289
         # prevent "Property access is not allowed yet" with @ on failure connections
282
-        if ($this->dbconn !== false && !is_null($this->dbconn))
283
-            @$this->dbconn->close();
290
+        if ($this->dbconn !== false && !is_null($this->dbconn)) {
291
+                    @$this->dbconn->close();
292
+        }
284 293
     }
285 294
 }
286 295
\ 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
@@ -94,20 +94,20 @@  discard block
 block discarded – undo
94 94
             {
95 95
                 foreach ($contents as $i)
96 96
                 {
97
-                    if (is_file($directory.'/'.$i))
97
+                    if (is_file($directory . '/' . $i))
98 98
                     {
99
-                        $allContents[] = $directory.'/'.$i;
99
+                        $allContents[] = $directory . '/' . $i;
100 100
 
101
-                        $this->buffer = $directory.'/'.$i;
101
+                        $this->buffer = $directory . '/' . $i;
102 102
                         call_user_func($fileCallback, $this);
103 103
                     }
104
-                    elseif (is_dir($directory.'/'.$i))
104
+                    elseif (is_dir($directory . '/' . $i))
105 105
                     {
106
-                        $allContents[] = $directory.'/'.$i;
106
+                        $allContents[] = $directory . '/' . $i;
107 107
 
108
-                        $this->getContents($directory.'/'.$i, $fileCallback, $dirCallback);
108
+                        $this->getContents($directory . '/' . $i, $fileCallback, $dirCallback);
109 109
 
110
-                        $this->buffer = $directory.'/'.$i;
110
+                        $this->buffer = $directory . '/' . $i;
111 111
                         call_user_func($dirCallback, $this);
112 112
 
113 113
                         /*$directory = scandir($directory);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                 if (!empty($path))
208 208
                     if (!strlen(stristr($item, $path)) > 0)
209 209
                         continue;
210
-                if (strstr($item,'~') === false && $item != '.' && $item != '..')
210
+                if (strstr($item, '~') === false && $item != '.' && $item != '..')
211 211
                     $filesToReturn[] = $item;
212 212
             }
213 213
         }
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
                     {
345 345
                         foreach ($files["folders"] as $folder)
346 346
                         {
347
-                            if (!file_exists($dest.'/'.$folder))
347
+                            if (!file_exists($dest . '/' . $folder))
348 348
                                 mkdir("$dest/$folder", 0777, true);
349 349
                         }
350 350
                     }
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
                         foreach ($files["files"] as $item)
355 355
                         {
356 356
                             if (!file_exists("$dest/$files"))
357
-                                copy($item, $dest.'/'.$item);
357
+                                copy($item, $dest . '/' . $item);
358 358
                         }
359 359
                     }
360 360
                 }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         if (is_dir($dest))
365 365
         {
366 366
             if (!$recursive)
367
-                copy($file, $dest.'/'.$file);
367
+                copy($file, $dest . '/' . $file);
368 368
             else {
369 369
 
370 370
                 $files = array();
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 
384 384
                     foreach ($files[1] as $item)
385 385
                     {
386
-                        if (!file_exists($dest.'/'.$item))
386
+                        if (!file_exists($dest . '/' . $item))
387 387
                             mkdir("$dest/$item", 0777, true);
388 388
                     }
389 389
 
390 390
                     foreach ($files[0] as $item)
391 391
                     {
392 392
                         if (!file_exists("$dest/$files"))
393
-                            copy($item, $dest.'/'.$item);
393
+                            copy($item, $dest . '/' . $item);
394 394
                     }
395 395
                 });
396 396
             }
@@ -415,12 +415,12 @@  discard block
 block discarded – undo
415 415
             throw new \InvalidArgumentException("Missing first parameter");
416 416
 
417 417
         if (is_dir($newfile))
418
-                $newfile .= '/'.basename($oldfile);
418
+                $newfile .= '/' . basename($oldfile);
419 419
 
420 420
         if ($oldfile == $newfile)
421 421
             throw new \Exception("'$oldfile' and '$newfile' are the same file");
422 422
 
423
-        if(!rename($oldfile, $newfile))
423
+        if (!rename($oldfile, $newfile))
424 424
             return false;
425 425
 
426 426
         return true;
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         else {
451 451
             if (!is_dir($dir))
452 452
             {
453
-                if(!mkdir("$dir", 0777))
453
+                if (!mkdir("$dir", 0777))
454 454
                     return false;
455 455
             }
456 456
         }
Please login to merge, or discard this patch.
Braces   +106 added lines, -82 removed lines patch added patch discarded remove patch
@@ -84,8 +84,9 @@  discard block
 block discarded – undo
84 84
         {
85 85
             foreach ($this->ls($directory) as $item)
86 86
             {
87
-                if ($item != '.' && $item != '..')
88
-                    $contents[] = $item;
87
+                if ($item != '.' && $item != '..') {
88
+                                    $contents[] = $item;
89
+                }
89 90
             }
90 91
 
91 92
             $allContents = $contents;
@@ -100,8 +101,7 @@  discard block
 block discarded – undo
100 101
 
101 102
                         $this->buffer = $directory.'/'.$i;
102 103
                         call_user_func($fileCallback, $this);
103
-                    }
104
-                    elseif (is_dir($directory.'/'.$i))
104
+                    } elseif (is_dir($directory.'/'.$i))
105 105
                     {
106 106
                         $allContents[] = $directory.'/'.$i;
107 107
 
@@ -117,14 +117,15 @@  discard block
 block discarded – undo
117 117
                     }
118 118
                 }
119 119
             }
120
+        } else if (is_file($directory)) {
121
+                    throw new \InvalidArgumentException("'$directory' is actually a file");
122
+        } else {
123
+                    throw new \InvalidArgumentException("The directory '$directory' does not exists");
120 124
         }
121
-        else if (is_file($directory))
122
-            throw new \InvalidArgumentException("'$directory' is actually a file");
123
-        else
124
-            throw new \InvalidArgumentException("The directory '$directory' does not exists");
125 125
 
126
-        if (!is_null($callback))
127
-            call_user_func($callback, $this);
126
+        if (!is_null($callback)) {
127
+                    call_user_func($callback, $this);
128
+        }
128 129
 
129 130
         return $allContents;
130 131
     }
@@ -136,10 +137,11 @@  discard block
 block discarded – undo
136 137
      */
137 138
     public function pwd()
138 139
     {
139
-        if (getcwd())
140
-            $this->buffer = getcwd();
141
-        else
142
-            return false;
140
+        if (getcwd()) {
141
+                    $this->buffer = getcwd();
142
+        } else {
143
+                    return false;
144
+        }
143 145
 
144 146
         return $this->buffer;
145 147
     }
@@ -158,9 +160,9 @@  discard block
 block discarded – undo
158 160
 
159 161
         $path = (is_null($path) || empty($path)) ? '.' : $path;
160 162
 
161
-        if (is_file($path))
162
-            $filesToReturn = array($path);
163
-        else if (is_dir($path))
163
+        if (is_file($path)) {
164
+                    $filesToReturn = array($path);
165
+        } else if (is_dir($path))
164 166
         {
165 167
             $pathIns = dir($path);
166 168
 
@@ -181,34 +183,37 @@  discard block
 block discarded – undo
181 183
                     }
182 184
                 );
183 185
 
184
-                foreach ($dirs as $item)
185
-                    $filesToReturn[] = $item;
186
+                foreach ($dirs as $item) {
187
+                                    $filesToReturn[] = $item;
188
+                }
186 189
 
187
-                foreach ($files as $item)
188
-                    $filesToReturn[] = $item;
189
-            }
190
-            else
190
+                foreach ($files as $item) {
191
+                                    $filesToReturn[] = $item;
192
+                }
193
+            } else
191 194
             {
192 195
                 while (($item = $pathIns->read()) !== false)
193 196
                 {
194
-                    if ($item != '.' && $item != '..')
195
-                        $filesToReturn[] = $item;
197
+                    if ($item != '.' && $item != '..') {
198
+                                            $filesToReturn[] = $item;
199
+                    }
196 200
                 }
197 201
 
198 202
                 $pathIns->close();
199 203
             }
200
-        }
201
-        else {
204
+        } else {
202 205
 
203 206
             $contents = $this->ls();
204 207
 
205 208
             foreach ($contents as $item)
206 209
             {
207
-                if (!empty($path))
208
-                    if (!strlen(stristr($item, $path)) > 0)
210
+                if (!empty($path)) {
211
+                                    if (!strlen(stristr($item, $path)) > 0)
209 212
                         continue;
210
-                if (strstr($item,'~') === false && $item != '.' && $item != '..')
211
-                    $filesToReturn[] = $item;
213
+                }
214
+                if (strstr($item,'~') === false && $item != '.' && $item != '..') {
215
+                                    $filesToReturn[] = $item;
216
+                }
212 217
             }
213 218
         }
214 219
 
@@ -228,8 +233,9 @@  discard block
 block discarded – undo
228 233
 
229 234
         if (is_dir($path))
230 235
         {
231
-            if (chdir($path))
232
-                return true;
236
+            if (chdir($path)) {
237
+                            return true;
238
+            }
233 239
         }
234 240
 
235 241
         return false;
@@ -271,12 +277,13 @@  discard block
 block discarded – undo
271 277
     {
272 278
         $recursive = is_null($recursive) ? false : $recursive;
273 279
 
274
-        if (is_null($file))
275
-            throw new \InvalidArgumentException("Missing first parameter");
280
+        if (is_null($file)) {
281
+                    throw new \InvalidArgumentException("Missing first parameter");
282
+        }
276 283
 
277
-        if (file_exists($file) && !$recursive)
278
-            unlink($file);
279
-        elseif (is_dir($file) && $recursive)
284
+        if (file_exists($file) && !$recursive) {
285
+                    unlink($file);
286
+        } elseif (is_dir($file) && $recursive)
280 287
         {
281 288
             $that = $this;
282 289
 
@@ -305,11 +312,13 @@  discard block
 block discarded – undo
305 312
     {
306 313
         $recursive = (is_null($recursive)) ? false : $recursive;
307 314
 
308
-        if (empty($file) || empty($dest))
309
-            throw new \InvalidArgumentException("Missing parameters");
315
+        if (empty($file) || empty($dest)) {
316
+                    throw new \InvalidArgumentException("Missing parameters");
317
+        }
310 318
 
311
-        if (is_dir($file) && !$recursive)
312
-            throw new \RuntimeException("Ommiting directory <<$foo>>");
319
+        if (is_dir($file) && !$recursive) {
320
+                    throw new \RuntimeException("Ommiting directory <<$foo>>");
321
+        }
313 322
 
314 323
         if (is_dir($file) && (is_dir($dest) || !file_exists($dest)))
315 324
         {
@@ -318,11 +327,13 @@  discard block
 block discarded – undo
318 327
                 "folders" => []
319 328
             ];
320 329
 
321
-            if (is_dir($dest))
322
-                $files["folders"][] = basename($file);
330
+            if (is_dir($dest)) {
331
+                            $files["folders"][] = basename($file);
332
+            }
323 333
 
324
-            if (!file_exists($dest))
325
-                mkdir($dest);
334
+            if (!file_exists($dest)) {
335
+                            mkdir($dest);
336
+            }
326 337
 
327 338
             $that = $this;
328 339
 
@@ -344,8 +355,9 @@  discard block
 block discarded – undo
344 355
                     {
345 356
                         foreach ($files["folders"] as $folder)
346 357
                         {
347
-                            if (!file_exists($dest.'/'.$folder))
348
-                                mkdir("$dest/$folder", 0777, true);
358
+                            if (!file_exists($dest.'/'.$folder)) {
359
+                                                            mkdir("$dest/$folder", 0777, true);
360
+                            }
349 361
                         }
350 362
                     }
351 363
 
@@ -353,8 +365,9 @@  discard block
 block discarded – undo
353 365
                     {
354 366
                         foreach ($files["files"] as $item)
355 367
                         {
356
-                            if (!file_exists("$dest/$files"))
357
-                                copy($item, $dest.'/'.$item);
368
+                            if (!file_exists("$dest/$files")) {
369
+                                                            copy($item, $dest.'/'.$item);
370
+                            }
358 371
                         }
359 372
                     }
360 373
                 }
@@ -363,9 +376,9 @@  discard block
 block discarded – undo
363 376
 
364 377
         if (is_dir($dest))
365 378
         {
366
-            if (!$recursive)
367
-                copy($file, $dest.'/'.$file);
368
-            else {
379
+            if (!$recursive) {
380
+                            copy($file, $dest.'/'.$file);
381
+            } else {
369 382
 
370 383
                 $files = array();
371 384
                 $files[0] = array();
@@ -383,20 +396,22 @@  discard block
 block discarded – undo
383 396
 
384 397
                     foreach ($files[1] as $item)
385 398
                     {
386
-                        if (!file_exists($dest.'/'.$item))
387
-                            mkdir("$dest/$item", 0777, true);
399
+                        if (!file_exists($dest.'/'.$item)) {
400
+                                                    mkdir("$dest/$item", 0777, true);
401
+                        }
388 402
                     }
389 403
 
390 404
                     foreach ($files[0] as $item)
391 405
                     {
392
-                        if (!file_exists("$dest/$files"))
393
-                            copy($item, $dest.'/'.$item);
406
+                        if (!file_exists("$dest/$files")) {
407
+                                                    copy($item, $dest.'/'.$item);
408
+                        }
394 409
                     }
395 410
                 });
396 411
             }
412
+        } else {
413
+                    copy($file, $dest);
397 414
         }
398
-        else
399
-            copy($file, $dest);
400 415
 
401 416
         return true;
402 417
     }
@@ -411,17 +426,21 @@  discard block
 block discarded – undo
411 426
      */
412 427
     public function mv($oldfile, $newfile)
413 428
     {
414
-        if (empty($oldfile))
415
-            throw new \InvalidArgumentException("Missing first parameter");
429
+        if (empty($oldfile)) {
430
+                    throw new \InvalidArgumentException("Missing first parameter");
431
+        }
416 432
 
417
-        if (is_dir($newfile))
418
-                $newfile .= '/'.basename($oldfile);
433
+        if (is_dir($newfile)) {
434
+                        $newfile .= '/'.basename($oldfile);
435
+        }
419 436
 
420
-        if ($oldfile == $newfile)
421
-            throw new \Exception("'$oldfile' and '$newfile' are the same file");
437
+        if ($oldfile == $newfile) {
438
+                    throw new \Exception("'$oldfile' and '$newfile' are the same file");
439
+        }
422 440
 
423
-        if(!rename($oldfile, $newfile))
424
-            return false;
441
+        if(!rename($oldfile, $newfile)) {
442
+                    return false;
443
+        }
425 444
 
426 445
         return true;
427 446
     }
@@ -437,21 +456,24 @@  discard block
 block discarded – undo
437 456
      */
438 457
     public function mkdir($dir, $dest = null, $recursive = null)
439 458
     {
440
-        if (empty($dir))
441
-            throw new \InvalidArgumentException("Missing first parameter");
459
+        if (empty($dir)) {
460
+                    throw new \InvalidArgumentException("Missing first parameter");
461
+        }
442 462
 
443
-        if (empty($dest))
444
-            $dest = '.';
463
+        if (empty($dest)) {
464
+                    $dest = '.';
465
+        }
445 466
 
446 467
         $recursive = (is_null($recursive)) ? false : $recursive;
447 468
 
448
-        if ($recursive)
449
-            mkdir("$dest/$dir", 0777, true);
450
-        else {
469
+        if ($recursive) {
470
+                    mkdir("$dest/$dir", 0777, true);
471
+        } else {
451 472
             if (!is_dir($dir))
452 473
             {
453
-                if(!mkdir("$dir", 0777))
454
-                    return false;
474
+                if(!mkdir("$dir", 0777)) {
475
+                                    return false;
476
+                }
455 477
             }
456 478
         }
457 479
         return true;
@@ -466,12 +488,14 @@  discard block
 block discarded – undo
466 488
      */
467 489
     public function rmdir($dir)
468 490
     {
469
-        if (is_null($dir) || empty($dir))
470
-            throw new Exception("Missing parameter for rmdir!");
491
+        if (is_null($dir) || empty($dir)) {
492
+                    throw new Exception("Missing parameter for rmdir!");
493
+        }
471 494
 
472
-        if (rmdir($dir))
473
-            return true;
474
-        else
475
-            return false;
495
+        if (rmdir($dir)) {
496
+                    return true;
497
+        } else {
498
+                    return false;
499
+        }
476 500
     }
477 501
 }
478 502
\ No newline at end of file
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.