1 | <?php |
||
12 | class File |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Read file content from local storage |
||
17 | * @param $path |
||
18 | * @return bool|string |
||
19 | */ |
||
20 | public static function read($path) |
||
30 | |||
31 | /** |
||
32 | * Check if $path is exist and readable in filesystem |
||
33 | * @param string $path |
||
34 | * @return bool |
||
35 | */ |
||
36 | public static function exist($path) |
||
41 | |||
42 | /** |
||
43 | * Alias for exist method |
||
44 | * @param string $path |
||
45 | * @return bool |
||
46 | */ |
||
47 | public static function readable($path) { |
||
50 | |||
51 | /** |
||
52 | * Check is file writable |
||
53 | * @param string $path |
||
54 | * @return bool |
||
55 | */ |
||
56 | public static function writable($path) |
||
66 | |||
67 | /** |
||
68 | * Check is file executable |
||
69 | * @param string $path |
||
70 | * @return bool |
||
71 | */ |
||
72 | public static function executable($path) |
||
82 | |||
83 | /** |
||
84 | * @param string $path |
||
85 | * @param null|string $content |
||
86 | * @param null|int $flags |
||
87 | * @return int |
||
88 | */ |
||
89 | public static function write($path, $content = null, $flags = null) |
||
102 | |||
103 | /** |
||
104 | * Remove file |
||
105 | * @param string $path |
||
106 | * @return bool |
||
107 | */ |
||
108 | public static function remove($path) |
||
117 | |||
118 | |||
119 | /** |
||
120 | * Alternative of functions include, require, include_once and etc in 1 function |
||
121 | * @param string $path |
||
122 | * @param bool|false $return |
||
123 | * @param bool|false $once |
||
124 | * @return bool|mixed |
||
125 | */ |
||
126 | public static function inc($path, $return = false, $once = false) |
||
140 | |||
141 | /** |
||
142 | * Get file make time in unix timestamp |
||
143 | * @param string $path |
||
144 | * @return int |
||
145 | */ |
||
146 | public static function mTime($path) |
||
155 | |||
156 | /** |
||
157 | * Recursive scan directory, based on $path and allowed extensions $ext or without it |
||
158 | * @param string $path |
||
159 | * @param array $ext |
||
160 | * @param bool $returnRelative |
||
161 | * @param $files |
||
162 | * @return array |
||
163 | */ |
||
164 | public static function listFiles($path, array $ext = null, $returnRelative = false, &$files = []) |
||
188 | |||
189 | } |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.