Passed
Push — master ( b176c5...1503d9 )
by Darío
01:55
created
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.