| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4.016 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 55 | public static function cleanUpDir(string $dir): bool |
|
| 34 | { |
||
| 35 | 55 | if (! file_exists($dir)) { |
|
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 39 | 55 | $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); |
|
| 40 | 55 | $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); |
|
| 41 | |||
| 42 | 55 | foreach ($files as $file) { |
|
| 43 | 55 | if ($file->isDir()) { |
|
| 44 | 47 | rmdir($file->getRealPath()); |
|
| 45 | } else { |
||
| 46 | 55 | unlink($file->getRealPath()); |
|
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | 55 | return rmdir($dir); |
|
| 51 | } |
||
| 52 | } |
||
| 53 |