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