| Conditions | 9 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 9 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 4 | protected function removeCycle(string $dirPath, string $sign = DIRECTORY_SEPARATOR): bool |
|
| 20 | { |
||
| 21 | 4 | $path = realpath($dirPath); |
|
| 22 | 4 | if (false === $path) { |
|
| 23 | 2 | return false; |
|
| 24 | } |
||
| 25 | 4 | if (is_dir($path)) { |
|
| 26 | 2 | $fileListing = scandir($path); |
|
| 27 | 2 | if (!empty($fileListing)) { |
|
| 28 | 2 | foreach ($fileListing as $fileName) { |
|
| 29 | 2 | if (is_dir($path . $sign . $fileName)) { |
|
| 30 | 2 | if (('.' != $fileName) && ('..' != $fileName)) { |
|
| 31 | 2 | $this->removeCycle($path . $sign . $fileName); |
|
| 32 | } |
||
| 33 | } else { |
||
| 34 | 2 | unlink($path . $sign . $fileName); |
|
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | 2 | rmdir($path); |
|
| 39 | 2 | } elseif (is_file($path)) { |
|
| 40 | 2 | unlink($path); |
|
| 41 | } |
||
| 42 | 4 | return true; |
|
| 43 | } |
||
| 45 |