| 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 |
||
| 32 | 27 | public static function cleanUpDir($dir) |
|
| 33 | { |
||
| 34 | 27 | if ( ! file_exists($dir)) { |
|
| 35 | return false; |
||
| 36 | } |
||
| 37 | |||
| 38 | 27 | $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); |
|
| 39 | 27 | $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); |
|
| 40 | |||
| 41 | 27 | foreach($files as $file) { |
|
| 42 | 27 | if ($file->isDir()){ |
|
| 43 | 27 | rmdir($file->getRealPath()); |
|
| 44 | 27 | } else { |
|
| 45 | 16 | unlink($file->getRealPath()); |
|
| 46 | } |
||
| 47 | 27 | } |
|
| 48 | |||
| 49 | 27 | return rmdir($dir); |
|
| 50 | } |
||
| 51 | } |
||
| 52 |