Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.016 |
Changes | 0 |
1 | <?php |
||
45 | 60 | public static function cleanUpDir(string $dir): bool |
|
46 | { |
||
47 | 60 | if (! file_exists($dir)) { |
|
48 | return false; |
||
49 | } |
||
50 | |||
51 | 60 | $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); |
|
52 | 60 | $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); |
|
53 | |||
54 | 60 | foreach ($files as $file) { |
|
55 | 60 | if ($file->isDir()) { |
|
56 | 52 | rmdir($file->getRealPath()); |
|
57 | } else { |
||
58 | 60 | unlink($file->getRealPath()); |
|
59 | } |
||
60 | } |
||
61 | |||
62 | 60 | return rmdir($dir); |
|
63 | } |
||
64 | } |
||
65 |