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