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 | * @throws exceptions\FileNotWriteableException |
||
46 | */ |
||
47 | 11 | public static function checkWritable(string $path): void |
|
53 | |||
54 | /** |
||
55 | * Check if a file is readable. |
||
56 | * In cases where the file cannot be read, an exception is thrown. |
||
57 | * |
||
58 | * @param string $path The path to the file to be checked. |
||
59 | * @throws exceptions\FileNotReadableException |
||
60 | */ |
||
61 | 11 | public static function checkReadable(string $path): void |
|
67 | |||
68 | /** |
||
69 | * Checks if a file exists and throws an exception if not. |
||
70 | * |
||
71 | * @param string $path |
||
72 | * @throws exceptions\FileNotFoundException |
||
73 | */ |
||
74 | 14 | public static function checkExists(string $path): void |
|
80 | |||
81 | /** |
||
82 | * Checks if a file exists and throws an exception if it does. |
||
83 | * |
||
84 | * @param string $path |
||
85 | * @throws exceptions\FileAlreadyExistsException |
||
86 | */ |
||
87 | 3 | public static function checkNotExists(string $path): void |
|
93 | |||
94 | /** |
||
95 | * Checks if a file exists and is writeable and throws a relevant exception if either condition is not met. |
||
96 | * |
||
97 | * @param $path |
||
98 | * @throws exceptions\FileNotFoundException |
||
99 | * @throws exceptions\FileNotWriteableException |
||
100 | */ |
||
101 | 7 | public static function checkWriteSafety($path) : void |
|
106 | |||
107 | /** |
||
108 | * Checks if a file exists and is readable and throws a relevant excetion if either condition is not met. |
||
109 | * |
||
110 | * @param $path |
||
111 | * @throws exceptions\FileNotFoundException |
||
112 | * @throws exceptions\FileNotReadableException |
||
113 | */ |
||
114 | 3 | public static function checkReadSafety($path) : void |
|
119 | |||
120 | /** |
||
121 | * Return an instance of the relevant FileInterface (File or Directory) for a file in a given path. |
||
122 | * |
||
123 | * @param string $path |
||
124 | * @return FileInterface |
||
125 | * @throws FileNotFoundException |
||
126 | */ |
||
127 | 1 | public static function get($path) : FileInterface |
|
136 | |||
137 | /** |
||
138 | * Return an instance of the File object for the given path. |
||
139 | * |
||
140 | * @param $path |
||
141 | * @return File |
||
142 | */ |
||
143 | 5 | public static function file($path) : File |
|
147 | |||
148 | /** |
||
149 | * Return an instance of the Directory object for the given path. |
||
150 | * |
||
151 | * @param $path |
||
152 | * @return Directory |
||
153 | */ |
||
154 | 5 | public static function directory($path) : Directory |
|
158 | |||
159 | /** |
||
160 | * Returns a file collection for all whose name match with the provided pattern. |
||
161 | * The format for the pattern is similar to those used by most shells as wildcards for selecting files. |
||
162 | * |
||
163 | * @param $pattern |
||
164 | * @return filesystem\FileCollection |
||
165 | */ |
||
166 | public static function glob($pattern) |
||
170 | |||
171 | /** |
||
172 | * Takes any path (relative or absolute) and returns its absolute form relative to a given path. When a relative |
||
173 | * path is not provided, the current working directory is used. |
||
174 | * |
||
175 | * @param $path |
||
176 | * @param null $relativeTo |
||
177 | * @return string |
||
178 | */ |
||
179 | public static function getAbsolutePath($path, $relativeTo = null) |
||
189 | } |
||
190 |