1 | <?php |
||
16 | class Directory |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * The absolute path of directory |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private $path; |
||
25 | |||
26 | /** |
||
27 | * Create new directory object |
||
28 | * |
||
29 | * @param string $path |
||
30 | */ |
||
31 | 3 | public function __construct($path) |
|
38 | |||
39 | /** |
||
40 | * Checks whether directory is empty or not |
||
41 | * |
||
42 | * @param string $filter |
||
43 | * The filter for entries to skip |
||
44 | * |
||
45 | * @return bool |
||
46 | * |
||
47 | * @throws DirectoryException |
||
48 | */ |
||
49 | 3 | public function isEmpty($filter = null): bool |
|
67 | |||
68 | /** |
||
69 | * Remove a directory |
||
70 | * |
||
71 | * @param boolean $recursive |
||
72 | * Whether to remove it if its not empty |
||
73 | * |
||
74 | * @throws DirectoryException |
||
75 | */ |
||
76 | 3 | public function remove($recursive = false) |
|
115 | |||
116 | /** |
||
117 | * Create a directory |
||
118 | * |
||
119 | * @param boolean $recursive |
||
120 | * Create also sub directories |
||
121 | * |
||
122 | * @throws DirectoryException |
||
123 | */ |
||
124 | 3 | public function create($recursive = false, $mode = 0755) |
|
139 | |||
140 | /** |
||
141 | * Checks whether directory exists |
||
142 | * |
||
143 | * @throws DirectoryException |
||
144 | * @return bool |
||
145 | */ |
||
146 | 3 | public function exists(): bool |
|
160 | |||
161 | /** |
||
162 | * Retrieve the path |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | 2 | public function getPath(): string |
|
170 | |||
171 | /** |
||
172 | * Check whether a particular file exist in directory |
||
173 | * |
||
174 | * @param string $fileName |
||
175 | * The file name to check |
||
176 | * |
||
177 | * @throws DirectoryException |
||
178 | * |
||
179 | * @return bool |
||
180 | */ |
||
181 | 1 | public function fileExists($fileName): bool |
|
191 | |||
192 | /** |
||
193 | * Generate a platform specific path by replacing invalid directory separators |
||
194 | * |
||
195 | * @param string $path |
||
196 | * The path to check |
||
197 | * @return string The corrected path |
||
198 | */ |
||
199 | 3 | private function fixDirectorySeparator($path): string |
|
206 | } |
||
207 |