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 |
||
12 | 1 | public function format(array $params): string |
|
13 | { |
||
14 | 1 | if (ArrayHelper::isAssociative($params)) { |
|
15 | 1 | $result = []; |
|
16 | |||
17 | 1 | $keys = array_keys($params); |
|
18 | 1 | foreach ($keys as $key) { |
|
19 | 1 | $element = Html::encode($key) . ':'; |
|
20 | |||
21 | 1 | if (is_array($params[$key])) { |
|
22 | 1 | $result[] = $element . $this->format($params[$key]); |
|
23 | 1 | continue; |
|
24 | } |
||
25 | |||
26 | 1 | $result[] = $element . '"' . Html::encode((string)$params[$key]) . '"'; |
|
27 | } |
||
28 | |||
29 | 1 | return '{' . implode(', ', $result) . '}'; |
|
30 | } |
||
31 | |||
32 | 1 | $result = array_map([Html::class, 'encode'], $params); |
|
33 | |||
34 | 1 | return '[' . implode(', ', $result) . ']'; |
|
35 | } |
||
37 |