1 | <?php |
||
38 | class Filesystem |
||
39 | { |
||
40 | /** |
||
41 | * Checks if a file is writeable. |
||
42 | * In cases where the file cannot be written to an exception is thrown. |
||
43 | * |
||
44 | * @param string $path The path to the file to be checked. |
||
45 | * @param string|null $message |
||
46 | * @throws exceptions\FileNotWriteableException |
||
47 | */ |
||
48 | 13 | public static function checkWritable(string $path, string $message = null): void |
|
54 | |||
55 | /** |
||
56 | * Check if a file is readable. |
||
57 | * In cases where the file cannot be read, an exception is thrown. |
||
58 | * |
||
59 | * @param string $path The path to the file to be checked. |
||
60 | * @param string|null $message |
||
61 | * @throws exceptions\FileNotReadableException |
||
62 | */ |
||
63 | 9 | public static function checkReadable(string $path, string $message = null): void |
|
69 | |||
70 | /** |
||
71 | * Checks if a file exists and throws an exception if not. |
||
72 | * |
||
73 | * @param string $path |
||
74 | * @param string|null $message |
||
75 | * @throws FileNotFoundException |
||
76 | */ |
||
77 | 13 | public static function checkExists(string $path, string $message = null): void |
|
83 | |||
84 | /** |
||
85 | * Checks if a file exists and throws an exception if it does. |
||
86 | * |
||
87 | * @param string $path |
||
88 | * @param string|null $message |
||
89 | * @throws exceptions\FileAlreadyExistsException |
||
90 | */ |
||
91 | 3 | public static function checkNotExists(string $path, string $message = null): void |
|
97 | |||
98 | /** |
||
99 | * Checks if a file exists and is writeable and throws a relevant exception if either condition is not met. |
||
100 | * |
||
101 | * @param string $path |
||
102 | * @param string|null $message |
||
103 | * @throws FileNotFoundException |
||
104 | * @throws exceptions\FileNotWriteableException |
||
105 | */ |
||
106 | 9 | public static function checkWriteSafety(string $path, string $message = null) : void |
|
111 | |||
112 | /** |
||
113 | * Checks if a file exists and is readable and throws a relevant excetion if either condition is not met. |
||
114 | * |
||
115 | * @param string $path |
||
116 | * @param string $message |
||
117 | * @throws FileNotFoundException |
||
118 | * @throws exceptions\FileNotReadableException |
||
119 | */ |
||
120 | public static function checkReadSafety(string $path, string $message) : void |
||
125 | |||
126 | /** |
||
127 | * Return an instance of the relevant FileInterface (File or Directory) for a file in a given path. |
||
128 | * |
||
129 | * @param string $path |
||
130 | * @return FileInterface |
||
131 | * @throws FileNotFoundException |
||
132 | */ |
||
133 | 1 | public static function get($path) : FileInterface |
|
142 | |||
143 | /** |
||
144 | * Return an instance of the File object for the given path. |
||
145 | * |
||
146 | * @param $path |
||
147 | * @return File |
||
148 | */ |
||
149 | 5 | public static function file($path) : File |
|
153 | |||
154 | /** |
||
155 | * Return an instance of the Directory object for the given path. |
||
156 | * |
||
157 | * @param $path |
||
158 | * @return Directory |
||
159 | */ |
||
160 | 5 | public static function directory($path) : Directory |
|
164 | |||
165 | /** |
||
166 | * Returns a file collection for all whose name match with the provided pattern. |
||
167 | * The format for the pattern is similar to those used by most shells as wildcards for selecting files. |
||
168 | * |
||
169 | * @param $pattern |
||
170 | * @return filesystem\FileCollection |
||
171 | */ |
||
172 | public static function glob($pattern) |
||
176 | |||
177 | /** |
||
178 | * Takes any path (relative or absolute) and returns its absolute form relative to a given path. When a relative |
||
179 | * path is not provided, the current working directory is used. |
||
180 | * |
||
181 | * @param $path |
||
182 | * @param null $relativeTo |
||
183 | * @return string |
||
184 | */ |
||
185 | public static function getAbsolutePath($path, $relativeTo = null) |
||
195 | } |
||
196 |