Conditions | 5 |
Paths | 9 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
49 | 1 | private function buildQuery(array $data, string $path = ''): string |
|
50 | { |
||
51 | 1 | $query = ''; |
|
52 | 1 | foreach ($data as $key => $value) { |
|
53 | 1 | $subPathKey = !is_int($key) ? $key : $this->numericPrefix.$key; |
|
54 | 1 | $subPath = '' !== $path ? $path.'['.$subPathKey.']' : $subPathKey; |
|
55 | |||
56 | 1 | if (is_array($value)) { |
|
57 | 1 | $query .= $this->buildQuery($value, $subPath); |
|
58 | } else { |
||
59 | 1 | $query .= $subPath.'='.urlencode((string) $value); |
|
60 | } |
||
61 | |||
62 | 1 | $query .= $this->argSeperator; |
|
63 | } |
||
64 | |||
65 | 1 | $query = substr($query, 0, -strlen($this->argSeperator)); |
|
66 | |||
67 | 1 | return $query; |
|
68 | } |
||
69 | } |
||
70 |