Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 1 | public function format(array $params): string |
|
18 | { |
||
19 | 1 | if (ArrayHelper::isAssociative($params)) { |
|
20 | 1 | $keys = array_keys($params); |
|
21 | 1 | $result = []; |
|
22 | |||
23 | 1 | foreach ($keys as $key) { |
|
24 | 1 | $element = Html::encode($key) . ':'; |
|
25 | |||
26 | 1 | if (is_array($params[$key])) { |
|
27 | 1 | $result[] = $element . $this->format($params[$key]); |
|
28 | 1 | continue; |
|
29 | } |
||
30 | |||
31 | 1 | $result[] = $element . '"' . Html::encode((string)$params[$key]) . '"'; |
|
32 | } |
||
33 | |||
34 | 1 | return '{' . implode(', ', $result) . '}'; |
|
35 | } |
||
36 | |||
37 | 1 | $result = array_map([Html::class, 'encode'], $params); |
|
38 | |||
39 | 1 | return '[' . implode(', ', $result) . ']'; |
|
40 | } |
||
42 |