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