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