Conditions | 4 |
Paths | 3 |
Total Lines | 32 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 27 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 2 | public function loadVars(string $source, $array): array |
|
18 | { |
||
19 | 2 | $entries = new Entries\FileEntry(); |
|
20 | 2 | $result = []; |
|
21 | 2 | foreach ($array as $postedKey => $posted) { |
|
22 | 2 | if (is_array($posted['name'])) { |
|
23 | 2 | foreach ($posted['name'] as $key => $value) { |
|
24 | 2 | $entry = clone $entries; |
|
25 | 2 | $entry->setEntry($source, sprintf('%s[%s]', $postedKey, $key)); |
|
26 | 2 | $entry->setFile( |
|
27 | 2 | $value, |
|
28 | 2 | $posted['tmp_name'][$key], |
|
29 | 2 | $posted['type'][$key], |
|
30 | 2 | intval($posted['error'][$key]), |
|
31 | 2 | intval($posted['size'][$key]) |
|
32 | 2 | ); |
|
33 | 2 | $result[] = $entry; |
|
34 | } |
||
35 | } else { |
||
36 | 2 | $entry = clone $entries; |
|
37 | 2 | $entry->setEntry($source, $postedKey); |
|
38 | 2 | $entry->setFile( |
|
39 | 2 | $posted['name'], |
|
40 | 2 | $posted['tmp_name'], |
|
41 | 2 | $posted['type'], |
|
42 | 2 | intval($posted['error']), |
|
43 | 2 | intval($posted['size']) |
|
44 | 2 | ); |
|
45 | 2 | $result[] = $entry; |
|
46 | } |
||
47 | } |
||
48 | 2 | return $result; |
|
49 | } |
||
51 |