1 | <?php |
||
13 | class GlobalFunctionsHelper |
||
14 | { |
||
15 | /** |
||
16 | * Wrapper around global function fopen() |
||
17 | * @see fopen() |
||
18 | * |
||
19 | * @param string $fileName |
||
20 | * @param string $mode |
||
21 | * @return resource|bool |
||
22 | */ |
||
23 | public function fopen($fileName, $mode) |
||
27 | |||
28 | /** |
||
29 | * Wrapper around global function fgets() |
||
30 | * @see fgets() |
||
31 | * |
||
32 | * @param resource $handle |
||
33 | * @param int|void $length |
||
34 | * @return string |
||
35 | */ |
||
36 | public function fgets($handle, $length = null) |
||
40 | |||
41 | /** |
||
42 | * Wrapper around global function fputs() |
||
43 | * @see fputs() |
||
44 | * |
||
45 | * @param resource $handle |
||
46 | * @param string $string |
||
47 | * @return int |
||
48 | */ |
||
49 | public function fputs($handle, $string) |
||
53 | |||
54 | /** |
||
55 | * Wrapper around global function fflush() |
||
56 | * @see fflush() |
||
57 | * |
||
58 | * @param resource $handle |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function fflush($handle) |
||
65 | |||
66 | /** |
||
67 | * Wrapper around global function fseek() |
||
68 | * @see fseek() |
||
69 | * |
||
70 | * @param resource $handle |
||
71 | * @param int $offset |
||
72 | * @return int |
||
73 | */ |
||
74 | public function fseek($handle, $offset) |
||
78 | |||
79 | /** |
||
80 | * Wrapper around global function fgetcsv() |
||
81 | * @see fgetcsv() |
||
82 | * |
||
83 | * @param resource $handle |
||
84 | * @param int|void $length |
||
85 | * @param string|void $delimiter |
||
86 | * @param string|void $enclosure |
||
87 | * @return array |
||
88 | */ |
||
89 | public function fgetcsv($handle, $length = null, $delimiter = null, $enclosure = null) |
||
93 | |||
94 | /** |
||
95 | * Wrapper around global function fputcsv() |
||
96 | * @see fputcsv() |
||
97 | * |
||
98 | * @param resource $handle |
||
99 | * @param array $fields |
||
100 | * @param string|void $delimiter |
||
101 | * @param string|void $enclosure |
||
102 | * @return int |
||
103 | */ |
||
104 | public function fputcsv($handle, array $fields, $delimiter = null, $enclosure = null) |
||
105 | { |
||
106 | return fputcsv($handle, $fields, $delimiter, $enclosure); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Wrapper around global function fwrite() |
||
111 | * @see fwrite() |
||
112 | * |
||
113 | * @param resource $handle |
||
114 | * @param string $string |
||
115 | * @return int |
||
116 | */ |
||
117 | public function fwrite($handle, $string) |
||
118 | { |
||
119 | return fwrite($handle, $string); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Wrapper around global function fclose() |
||
124 | * @see fclose() |
||
125 | * |
||
126 | * @param resource $handle |
||
127 | * @return bool |
||
128 | */ |
||
129 | public function fclose($handle) |
||
133 | |||
134 | /** |
||
135 | * Wrapper around global function rewind() |
||
136 | * @see rewind() |
||
137 | * |
||
138 | * @param resource $handle |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function rewind($handle) |
||
145 | |||
146 | /** |
||
147 | * Wrapper around global function file_exists() |
||
148 | * @see file_exists() |
||
149 | * |
||
150 | * @param string $fileName |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function file_exists($fileName) |
||
157 | |||
158 | /** |
||
159 | * Wrapper around global function file_get_contents() |
||
160 | * @see file_get_contents() |
||
161 | * |
||
162 | * @param string $filePath |
||
163 | * @return string |
||
164 | */ |
||
165 | public function file_get_contents($filePath) |
||
170 | |||
171 | /** |
||
172 | * Updates the given file path to use a real path. |
||
173 | * This is to avoid issues on some Windows setup. |
||
174 | * |
||
175 | * @param string $filePath File path |
||
176 | * @return string The file path using a real path |
||
177 | */ |
||
178 | protected function convertToUseRealPath($filePath) |
||
194 | |||
195 | /** |
||
196 | * Returns whether the given path is a zip stream. |
||
197 | * |
||
198 | * @param string $path Path pointing to a document |
||
199 | * @return bool TRUE if path is a zip stream, FALSE otherwise |
||
200 | */ |
||
201 | protected function isZipStream($path) |
||
205 | |||
206 | /** |
||
207 | * Wrapper around global function dirname() |
||
208 | * @see dirname() |
||
209 | * |
||
210 | * @param string $filePath |
||
211 | * @return string |
||
212 | */ |
||
213 | public function dirname($filePath) |
||
217 | |||
218 | /** |
||
219 | * Wrapper around global function feof() |
||
220 | * @see feof() |
||
221 | * |
||
222 | * @param resource |
||
223 | * @return bool |
||
224 | */ |
||
225 | public function feof($handle) |
||
229 | |||
230 | /** |
||
231 | * Wrapper around global function is_readable() |
||
232 | * @see is_readable() |
||
233 | * |
||
234 | * @param string $fileName |
||
235 | * @return bool |
||
236 | */ |
||
237 | public function is_readable($fileName) |
||
241 | |||
242 | /** |
||
243 | * Wrapper around global function basename() |
||
244 | * @see basename() |
||
245 | * |
||
246 | * @param string $path |
||
247 | * @param string|void $suffix |
||
248 | * @return string |
||
249 | */ |
||
250 | public function basename($path, $suffix = null) |
||
254 | |||
255 | /** |
||
256 | * Wrapper around global function header() |
||
257 | * @see header() |
||
258 | * |
||
259 | * @param string $string |
||
260 | * @return void |
||
261 | */ |
||
262 | public function header($string) |
||
266 | |||
267 | /** |
||
268 | * Wrapper around global function ob_end_clean() |
||
269 | * @see ob_end_clean() |
||
270 | * |
||
271 | * @return void |
||
272 | */ |
||
273 | public function ob_end_clean() |
||
279 | |||
280 | /** |
||
281 | * Wrapper around global function iconv() |
||
282 | * @see iconv() |
||
283 | * |
||
284 | * @param string $string The string to be converted |
||
285 | * @param string $sourceEncoding The encoding of the source string |
||
286 | * @param string $targetEncoding The encoding the source string should be converted to |
||
287 | * @return string|bool the converted string or FALSE on failure. |
||
288 | */ |
||
289 | public function iconv($string, $sourceEncoding, $targetEncoding) |
||
293 | |||
294 | /** |
||
295 | * Wrapper around global function mb_convert_encoding() |
||
296 | * @see mb_convert_encoding() |
||
297 | * |
||
298 | * @param string $string The string to be converted |
||
299 | * @param string $sourceEncoding The encoding of the source string |
||
300 | * @param string $targetEncoding The encoding the source string should be converted to |
||
301 | * @return string|bool the converted string or FALSE on failure. |
||
302 | */ |
||
303 | public function mb_convert_encoding($string, $sourceEncoding, $targetEncoding) |
||
307 | |||
308 | /** |
||
309 | * Wrapper around global function stream_get_wrappers() |
||
310 | * @see stream_get_wrappers() |
||
311 | * |
||
312 | * @return array |
||
313 | */ |
||
314 | public function stream_get_wrappers() |
||
318 | |||
319 | /** |
||
320 | * Wrapper around global function function_exists() |
||
321 | * @see function_exists() |
||
322 | * |
||
323 | * @param string $functionName |
||
324 | * @return bool |
||
325 | */ |
||
326 | public function function_exists($functionName) |
||
330 | } |
||
331 |