1 | <?php |
||
14 | class FileLoader |
||
15 | { |
||
16 | /** |
||
17 | * The data which will be decoded. |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $dataToDecode = []; |
||
21 | |||
22 | /** |
||
23 | * The array of supported Mime types, which is defined in each decoder class. |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $supportedMimeTypes = []; |
||
27 | |||
28 | /** |
||
29 | * A container for the SPLFileInfo objects |
||
30 | * @var FileBag |
||
31 | */ |
||
32 | protected $fileBag; |
||
33 | |||
34 | /** |
||
35 | * An array holding data about the loaded decoders. |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $decoders = []; |
||
39 | |||
40 | /** |
||
41 | * Should there be an attempt to load an unsupported file type (determined by the mime types array), then they |
||
42 | * will be stored in this array for later display in an error message. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $unsupportedFiles = []; |
||
47 | |||
48 | /** |
||
49 | * The data array, once it has been processed through a decoder. |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $decodedData = []; |
||
53 | |||
54 | /** |
||
55 | * Add a file decoder to the FileLoader |
||
56 | * @param DecoderInterface $decoder |
||
57 | */ |
||
58 | public function addDecoder(DecoderInterface $decoder) |
||
69 | |||
70 | /** |
||
71 | * Add a file bag, or change an array of SplFileInfo Objects to proper objects. |
||
72 | * |
||
73 | * @param mixed $files a FileBag or an array of SplFileInfo objects. |
||
74 | */ |
||
75 | public function addFiles($files) |
||
89 | |||
90 | /** |
||
91 | * Process the current FileBag and return an array |
||
92 | * @return array |
||
93 | * @throws Exception |
||
94 | */ |
||
95 | public function process() |
||
99 | |||
100 | /** |
||
101 | * Process file bag to load into the data manager. |
||
102 | * A file bag is an array of SplFileInfo objects. |
||
103 | * |
||
104 | * @param array|FileBag $fileBag |
||
105 | * @return array |
||
106 | * @throws Exception |
||
107 | */ |
||
108 | public function decodeFileBagData(FileBag $fileBag) |
||
137 | |||
138 | /** |
||
139 | * Check to make sure the mime type is ok. |
||
140 | * @param $type a mime type |
||
141 | * @return bool |
||
142 | */ |
||
143 | protected function isSupportedMimeType($type) |
||
147 | |||
148 | /** |
||
149 | * Returns the contents of the file. |
||
150 | * |
||
151 | * @return string the contents of the file |
||
152 | * @throws \RuntimeException |
||
153 | */ |
||
154 | protected function getFileContents($file) |
||
170 | |||
171 | /** |
||
172 | * Default decoder class factory method. |
||
173 | * Checks to make sure we have a default decoder available and if so, adds it as a decoder to the file loader. |
||
174 | * |
||
175 | * @param $mimeType |
||
176 | */ |
||
177 | protected function checkAndAddDefaultDecoder($mimeType) |
||
188 | |||
189 | /** |
||
190 | * Decodes a single file using registered decoders |
||
191 | * @param $file |
||
192 | * @return null |
||
193 | */ |
||
194 | protected function decodeFile($file) |
||
208 | |||
209 | /** |
||
210 | * Returns currently attached custom decoders |
||
211 | * @return array |
||
212 | */ |
||
213 | public function getDecoders() |
||
217 | |||
218 | /** |
||
219 | * Returns currently supported Mime Types |
||
220 | * @return array |
||
221 | */ |
||
222 | public function getMimeTypes() |
||
226 | |||
227 | /** |
||
228 | * Cleans up a file name for use as a namespace |
||
229 | * @param $ns |
||
230 | * @return mixed |
||
231 | */ |
||
232 | public function sanitizeNamespace($ns) |
||
248 | |||
249 | /** |
||
250 | * Gets or creates the file's namespace |
||
251 | * @param $file |
||
252 | * @return array with the namespace and fileobject |
||
253 | */ |
||
254 | protected function getFilesNamespace($file) |
||
271 | } |
||
272 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.