1 | <?php |
||
16 | class FilesFactory implements Factory |
||
17 | { |
||
18 | /** |
||
19 | * Create instances of UploadedFile object from instance of Enviroment object |
||
20 | * |
||
21 | * @param Enviroment $enviroment enviroment data |
||
22 | * |
||
23 | * @return array An associative array containing instances of UploadedFile, if there |
||
24 | * are no uploads an empty array will be returned: |
||
25 | * [<field name> => <instance of UploadedFile>, ...] |
||
26 | */ |
||
27 | 3 | public function create(Enviroment $enviroment) |
|
28 | { |
||
29 | 3 | $files = $enviroment->getFiles(); |
|
30 | 3 | $parsed = $this->parseFiles($files); |
|
31 | |||
32 | 3 | return $parsed; |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * Parse files data into instances of UploadedFile |
||
37 | * |
||
38 | * @param array $files An associative array of items with same structure as $_FILES |
||
39 | * |
||
40 | * @return array An associative array containing instances of UploadedFile, if there |
||
41 | * are no uploads an empty array will be returned: |
||
42 | * [<field name> => <instance of UploadedFile>, ...] |
||
43 | */ |
||
44 | 3 | private function parseFiles($files) |
|
55 | |||
56 | /** |
||
57 | * Parse particular fields in files data into instances of UploadedFile |
||
58 | * |
||
59 | * @param array $uploadedFile An associative array of items from $_FILES from one single field |
||
60 | * |
||
61 | * @return array array with instances of UploadedFile |
||
62 | */ |
||
63 | 2 | private function parseFile($uploadedFile) |
|
91 | } |
||
92 |