1 | <?php |
||
35 | class FileInfo |
||
36 | { |
||
37 | const INFO_NONE = 0; |
||
38 | const INFO_PATH = 1; |
||
39 | const INFO_SIZE = 2; |
||
40 | const INFO_DATE = 4; |
||
41 | const INFO_PERMISSION = 8; |
||
42 | const INFO_TYPE = 16; |
||
43 | const INFO_ALL = 65535; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $file; |
||
49 | |||
50 | /** |
||
51 | * @var int |
||
52 | */ |
||
53 | private $infoParts; |
||
54 | |||
55 | /** |
||
56 | * @var PathInfo |
||
57 | */ |
||
58 | private $pathInfo; |
||
59 | |||
60 | /** |
||
61 | * @var PathInfoFactory |
||
62 | */ |
||
63 | private $pathInfoFactory; |
||
64 | |||
65 | /** |
||
66 | * @var SizeInfo |
||
67 | */ |
||
68 | private $sizeInfo; |
||
69 | |||
70 | /** |
||
71 | * @var SizeInfoFactory |
||
72 | */ |
||
73 | private $sizeInfoFactory; |
||
74 | |||
75 | /** |
||
76 | * @var DateInfo |
||
77 | */ |
||
78 | private $dateInfo; |
||
79 | |||
80 | /** |
||
81 | * @var DateInfoFactory |
||
82 | */ |
||
83 | private $dateInfoFactory; |
||
84 | |||
85 | /** |
||
86 | * @var PermissionInfo |
||
87 | */ |
||
88 | private $permissionInfo; |
||
89 | |||
90 | /** |
||
91 | * @var PermissionInfoFactory |
||
92 | */ |
||
93 | private $permissionInfoFactory; |
||
94 | |||
95 | /** |
||
96 | * @var TypeInfo |
||
97 | */ |
||
98 | private $typeInfo; |
||
99 | |||
100 | /** |
||
101 | * @var TypeInfoFactory |
||
102 | */ |
||
103 | private $typeInfoFactory; |
||
104 | |||
105 | /** |
||
106 | * Constructor. |
||
107 | * |
||
108 | * @param string $file Path and filename of the file. |
||
109 | * @param int $infoParts Bitmask of INFO_* constants. |
||
110 | * Parts which are not in the provided bitmask will not |
||
111 | * be analyzed, so the getters for them will |
||
112 | * throw an UnavailableException. |
||
113 | * @param PathInfoFactory $pathInfoFactory Factory for path information value objects. |
||
114 | * @param SizeInfoFactory $sizeInfoFactory Factory for size information value objects. |
||
115 | * @param DateInfoFactory $dateInfoFactory Factory for date information value objects. |
||
116 | * @param PermissionInfoFactory $permissionInfoFactory Factory for permission information value objects. |
||
117 | * @param TypeInfoFactory $typeInfoFactory Factory for type information value objects. |
||
118 | * |
||
119 | * @throws FileUnreadableException |
||
120 | */ |
||
121 | 14 | public function __construct( |
|
141 | |||
142 | /** |
||
143 | * Reloads the file infos. |
||
144 | * |
||
145 | * @param int $infoParts During reload, different or more info parts can be retrieved. |
||
146 | * If $infoParts is null, the previous value is used. |
||
147 | * |
||
148 | * @return self |
||
149 | */ |
||
150 | 1 | public function reload($infoParts = null) |
|
156 | |||
157 | /** |
||
158 | * Returns the path information. |
||
159 | * |
||
160 | * @return PathInfo |
||
161 | * |
||
162 | * @throws UnavailableException |
||
163 | */ |
||
164 | 5 | public function getPathInfo() |
|
172 | |||
173 | /** |
||
174 | * Alias for getPathInfo(). |
||
175 | */ |
||
176 | 1 | public function path() |
|
180 | |||
181 | /** |
||
182 | * Returns the size information. |
||
183 | * |
||
184 | * @return SizeInfo |
||
185 | * |
||
186 | * @throws UnavailableException |
||
187 | */ |
||
188 | 2 | public function getSizeInfo() |
|
196 | |||
197 | /** |
||
198 | * Alias for getSizeInfo(). |
||
199 | */ |
||
200 | 1 | public function size() |
|
204 | |||
205 | /** |
||
206 | * Returns the size information. |
||
207 | * |
||
208 | * @return DateInfo |
||
209 | * |
||
210 | * @throws UnavailableException |
||
211 | */ |
||
212 | 2 | public function getDateInfo() |
|
220 | |||
221 | /** |
||
222 | * Alias for getDateInfo(). |
||
223 | */ |
||
224 | 1 | public function date() |
|
228 | |||
229 | /** |
||
230 | * Returns the permission information. |
||
231 | * |
||
232 | * @return PermissionInfo |
||
233 | * |
||
234 | * @throws UnavailableException |
||
235 | */ |
||
236 | 2 | public function getPermissionInfo() |
|
244 | |||
245 | /** |
||
246 | * Alias for getPermissionInfo(). |
||
247 | */ |
||
248 | 1 | public function perm() |
|
252 | |||
253 | /** |
||
254 | * Returns the type information. |
||
255 | * |
||
256 | * @return TypeInfo |
||
257 | * |
||
258 | * @throws UnavailableException |
||
259 | */ |
||
260 | 2 | public function getTypeInfo() |
|
268 | |||
269 | /** |
||
270 | * Alias for getTypeInfo(). |
||
271 | */ |
||
272 | 1 | public function type() |
|
276 | |||
277 | /** |
||
278 | * Reloads the file infos. |
||
279 | * |
||
280 | * @param int $infoParts |
||
281 | * |
||
282 | * @throws FileUnreadableException |
||
283 | */ |
||
284 | 14 | private function reloadFileInformation($infoParts = null) |
|
318 | } |
||
319 |