Conditions | 6 |
Paths | 7 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 6 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
19 | private function buildQuery(array $data, string $path = ''): string |
||
20 | { |
||
21 | if ([] === $data) { |
||
22 | 2 | return ''; |
|
23 | } |
||
24 | 2 | ||
25 | $query = ''; |
||
26 | foreach ($data as $key => $value) { |
||
27 | if (null === $value) { |
||
28 | continue; |
||
29 | } |
||
30 | |||
31 | $subPath = '' !== $path ? $path.'['.$key.']' : (string) $key; |
||
32 | if (is_array($value)) { |
||
33 | 2 | $query .= $this->buildQuery($value, $subPath); |
|
34 | } else { |
||
35 | 2 | $query .= $subPath.'='.urlencode($this->getValueAsString($value)); |
|
36 | 1 | } |
|
37 | $query .= '&'; |
||
38 | } |
||
39 | 2 | ||
40 | 2 | return substr($query, 0, -strlen('&')); |
|
41 | 2 | } |
|
74 |