| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public static function removeDir(string $target): void |
||
| 15 | { |
||
| 16 | if (!is_dir($target)) { |
||
| 17 | return; |
||
| 18 | } |
||
| 19 | |||
| 20 | $files = new RecursiveIteratorIterator( |
||
| 21 | new RecursiveDirectoryIterator($target, FilesystemIterator::SKIP_DOTS), |
||
| 22 | RecursiveIteratorIterator::CHILD_FIRST |
||
| 23 | ); |
||
| 24 | |||
| 25 | /** @var SplFileInfo $file */ |
||
| 26 | foreach ($files as $file) { |
||
| 27 | if (is_dir($file->getPathname())) { |
||
| 28 | rmdir($file->getPathname()); |
||
| 29 | } else { |
||
| 30 | unlink($file->getPathname()); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | rmdir($target); |
||
| 35 | } |
||
| 37 |