Total Complexity | 12 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 96.67% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait ConvertsIdToKey |
||
8 | { |
||
9 | 225 | public function convertIdToKey(mixed $data): mixed |
|
10 | { |
||
11 | 225 | if (is_array($data) && array_is_list($data)) { |
|
12 | 4 | foreach($data as $key => $value) { |
|
13 | 4 | $data[$key] = $this->convertIdInString($value); |
|
14 | } |
||
15 | 4 | return $data; |
|
16 | } |
||
17 | |||
18 | 225 | if (!is_array($data) && !is_string($data)) { |
|
19 | 1 | return $data; |
|
20 | } |
||
21 | |||
22 | 225 | if (is_string($data)) { |
|
23 | 223 | return $this->convertIdInString($data); |
|
24 | } |
||
25 | |||
26 | 38 | return $this->convertIdInArrayKeys($data); |
|
27 | } |
||
28 | |||
29 | 225 | protected function convertIdInString(string $data): string |
|
42 | 225 | ); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param array<mixed> $data |
||
47 | * @return array<mixed> |
||
48 | */ |
||
49 | 38 | protected function convertIdInArrayKeys(array $data): array |
|
66 |