Total Complexity | 7 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class VarsAdapter extends AAdapter |
||
11 | { |
||
12 | protected string $inputType = ''; |
||
13 | |||
14 | 3 | public function loadEntries(string $inputType): void |
|
15 | { |
||
16 | 3 | if (IEntry::SOURCE_POST == $inputType) { |
|
17 | 1 | $this->vars = $this->loadVars($_POST); |
|
18 | 2 | } elseif (IEntry::SOURCE_GET == $inputType) { |
|
19 | 1 | $this->vars = $this->loadVars($_GET); |
|
20 | } else { |
||
21 | 1 | throw new FormsException(sprintf('Unknown input type - %s', $inputType)); |
|
22 | } |
||
23 | 2 | $this->inputType = $inputType; |
|
24 | 2 | } |
|
25 | |||
26 | /** |
||
27 | * @param array<string|int, string|int|float|bool|null>|null $array |
||
28 | * @return array<string, string> |
||
29 | */ |
||
30 | 3 | protected function loadVars(&$array): array |
|
31 | { |
||
32 | 3 | $result = []; |
|
33 | 3 | if (is_array($array)) { |
|
34 | 2 | foreach ($array as $postedKey => $posted) { |
|
35 | 1 | $result[$this->removeNullBytes(strval($postedKey))] = $this->removeNullBytes(strval($posted)); |
|
36 | } |
||
37 | } |
||
38 | 3 | return $result; |
|
39 | } |
||
40 | |||
41 | 4 | public function getSource(): string |
|
44 | } |
||
45 | } |
||
46 |