| Conditions | 6 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | function rrmdir(string $directory): bool |
||
| 16 | { |
||
| 17 | 1 | if (is_dir($directory)) { |
|
| 18 | |||
| 19 | 1 | $objects = scandir($directory, SCANDIR_SORT_NONE); |
|
| 20 | |||
| 21 | 1 | foreach ($objects as $object) { |
|
| 22 | |||
| 23 | 1 | if ($object !== '.' && $object !== '..') { |
|
| 24 | |||
| 25 | 1 | $currentDirectory = create_directory_path([$directory, $object]); |
|
| 26 | |||
| 27 | 1 | if (filetype($currentDirectory) === 'dir') { |
|
| 28 | 1 | rrmdir($currentDirectory); |
|
| 29 | } else { |
||
| 30 | 1 | unlink($currentDirectory); |
|
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 | 1 | reset($objects); |
|
| 35 | |||
| 36 | 1 | return rmdir($directory); |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | return false; |
|
| 40 | } |
||
| 41 | |||
| 46 |