| Conditions | 5 |
| Paths | 4 |
| Total Lines | 32 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | 7 | public function loadVars(string $source, $array): array |
|
| 17 | { |
||
| 18 | 7 | $fileEntries = new Entries\FileEntry(); |
|
| 19 | 7 | $entries = new Entries\Entry(); |
|
| 20 | 7 | $result = []; |
|
| 21 | 7 | foreach ($array as $postedKey => $posted) { |
|
| 22 | 3 | if (is_array($posted) && isset($posted['FILE'])) { |
|
| 23 | 1 | $file = tempnam(sys_get_temp_dir(), 'js_'); |
|
| 24 | 1 | if (false === $file) { |
|
| 25 | // @codeCoverageIgnoreStart |
||
| 26 | continue; |
||
| 27 | } |
||
| 28 | // @codeCoverageIgnoreEnd |
||
| 29 | 1 | $size = file_put_contents($file, $posted['FILE']); |
|
| 30 | |||
| 31 | 1 | $entry = clone $fileEntries; |
|
| 32 | 1 | $entry->setEntry($source, strval($postedKey)); |
|
| 33 | 1 | $entry->setFile( |
|
| 34 | 1 | $postedKey . '.json', |
|
| 35 | $file, |
||
| 36 | 'application/octet-stream', |
||
| 37 | 0, |
||
| 38 | 1 | intval($size) |
|
| 39 | ); |
||
| 40 | 1 | $result[] = $entry; |
|
| 41 | } else { |
||
| 42 | 3 | $entry = clone $entries; |
|
| 43 | 3 | $entry->setEntry($source, strval($postedKey), $posted); |
|
| 44 | 3 | $result[] = $entry; |
|
| 45 | } |
||
| 46 | } |
||
| 47 | 7 | return $result; |
|
| 48 | } |
||
| 50 |