| Total Complexity | 11 | 
| Total Lines | 50 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 11 | class Directory | ||
| 12 | { | ||
| 13 | /** | ||
| 14 | * @var string | ||
| 15 | */ | ||
| 16 | private static $rootPath = '.'; | ||
| 17 | /** | ||
| 18 | * @var string | ||
| 19 | */ | ||
| 20 | private static $parentPath = '..'; | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @param $path | ||
| 24 | * | ||
| 25 | * http://php.net/manual/en/function.rmdir.php#119949 | ||
| 26 | */ | ||
| 27 | public static function removeRecursively($path): void | ||
| 28 |     { | ||
| 29 |         if (\file_exists($path)) { | ||
| 30 | $dir = \opendir($path); | ||
| 31 |             if (\is_resource($dir)) { | ||
| 32 |                 while (false !== ($file = \readdir($dir))) { | ||
| 33 |                     if (($file !== self::$rootPath) && ($file !== self::$parentPath)) { | ||
| 34 | $full = $path . DIRECTORY_SEPARATOR . $file; | ||
| 35 |                         if (\is_dir($full)) { | ||
| 36 | self::removeRecursively($full); | ||
| 37 |                         } else { | ||
| 38 | \unlink($full); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | \closedir($dir); | ||
| 43 | } | ||
| 44 | \rmdir($path); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | /** | ||
| 49 | * @param $path | ||
| 50 | * @param $permissions | ||
| 51 | * | ||
| 52 | * @return bool | ||
| 53 | * @throws \Exception | ||
| 54 | */ | ||
| 55 | public static function create($path, $permissions = 0755): bool | ||
| 61 | } | ||
| 62 | } |