1 | <?php |
||
11 | class FileBag |
||
12 | { |
||
13 | /** |
||
14 | * Initialize bag from $_FILES. |
||
15 | * |
||
16 | * @throws \InvalidArgumentException |
||
17 | */ |
||
18 | public function __construct() |
||
29 | |||
30 | /** |
||
31 | * Returns true if the FILE parameter is defined. |
||
32 | * |
||
33 | * @param string $key |
||
34 | * |
||
35 | * @return bool |
||
36 | */ |
||
37 | public function has($key) |
||
41 | |||
42 | /** |
||
43 | * An array of parameter names. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function keys() |
||
51 | |||
52 | /** |
||
53 | * Get value by parameter name. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * @param mixed|null $default The default value if parameter does not exist |
||
57 | * |
||
58 | * @return FileUpload|array|null |
||
59 | */ |
||
60 | public function fetch($key, $default = null) |
||
64 | |||
65 | /** |
||
66 | * Converts uploaded files to FileUpload instances. |
||
67 | * |
||
68 | * @param array|FileUpload $file A (multi-dimensional) array of uploaded file information |
||
69 | * |
||
70 | * @return array A (multi-dimensional) array of FileUpload instances |
||
71 | */ |
||
72 | private function convertFileInformation($file) |
||
96 | |||
97 | /** |
||
98 | * Fixes a malformed PHP $_FILES array. |
||
99 | * |
||
100 | * PHP has a bug that the format of the $_FILES array differs, depending on |
||
101 | * whether the uploaded file fields had normal field names or array-like |
||
102 | * field names ("normal" vs. "parent[child]"). |
||
103 | * |
||
104 | * This method fixes the array to look like the "normal" $_FILES array. |
||
105 | * |
||
106 | * It's safe to pass an already converted array, in which case this method |
||
107 | * just returns the original array unmodified. |
||
108 | * |
||
109 | * @param array $data |
||
110 | * |
||
111 | * @return array |
||
112 | */ |
||
113 | private function fixPhpFilesArray($data) |
||
143 | |||
144 | private $bag; |
||
145 | } |