1 | <?php |
||
11 | final class File |
||
12 | { |
||
13 | /** |
||
14 | * Recursively deletes directory contents |
||
15 | * |
||
16 | * @param string $directoryPath absolute path of directory |
||
17 | * |
||
18 | * @return void |
||
19 | * |
||
20 | * @throws \InvalidArgumentException if $directoryPath is not a string |
||
21 | * @throws \Exception if file cannot be deleted |
||
22 | * @throws \Exception if directory cannot be deleted |
||
23 | * @throws \Exception if $directoryPath cannot be listed |
||
24 | */ |
||
25 | public static function deleteDirectoryContents($directoryPath) |
||
55 | |||
56 | /** |
||
57 | * Deletes the given file specified by $path |
||
58 | * |
||
59 | * @param string $path path to the file to be deleted |
||
60 | * |
||
61 | * @return void |
||
62 | * |
||
63 | * @throws \InvalidArgumentException if $path is not a string or is whitespace |
||
64 | * throws \Exception if unlink returns false |
||
65 | */ |
||
66 | public static function delete($path) |
||
86 | |||
87 | /** |
||
88 | * Recursively deletes the given directory path until a non-empty directory is found or the $stopAtPath is reached. |
||
89 | * |
||
90 | * @param string $deletePath The empty directory path to delete. |
||
91 | * @param string $stopAtPath The point at which the deletion should stop. Defaults to /. |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | public static function deletePathIfEmpty($deletePath, $stopAtPath = '/') |
||
122 | } |
||
123 |