1 | <?php |
||
13 | /** |
||
14 | * Recursively deletes directory contents |
||
15 | * |
||
16 | * @param string $directoryPath absolute path of directory |
||
17 | * |
||
18 | * @return void |
||
19 | * |
||
20 | * @throws \Exception if file cannot be deleted |
||
21 | * @throws \Exception if directory cannot be deleted |
||
22 | * @throws \Exception if $directoryPath cannot be listed |
||
23 | */ |
||
24 | public static function deleteDirectoryContents(string $directoryPath) |
||
47 | |||
48 | /** |
||
49 | * Deletes the given file specified by $path |
||
50 | * |
||
51 | * @param string $path path to the file to be deleted |
||
52 | * |
||
53 | * @return void |
||
54 | * |
||
55 | * @throws \InvalidArgumentException if $path is whitespace |
||
56 | * @throws \Exception if unlink returns false |
||
57 | */ |
||
58 | public static function delete(string $path) |
||
76 | |||
77 | /** |
||
78 | * Recursively deletes the given directory path until a non-empty directory is found or the $stopAtPath is reached. |
||
79 | * |
||
80 | * @param string $deletePath The empty directory path to delete. |
||
81 | * @param string $stopAtPath The point at which the deletion should stop. Defaults to /. |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public static function deletePathIfEmpty(string $deletePath, string $stopAtPath = '/') |
||
112 | |||
113 | private static function throwIfFalse($condition, string $message, int $code = 0) |
||
119 | } |
||
120 |