Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
13 | function iterable_separate(iterable $iterable): array |
||
|
|||
14 | { |
||
15 | 7 | if (is_array($iterable)) { |
|
16 | 1 | return ['keys' => array_keys($iterable), 'values' => array_values($iterable)]; |
|
17 | } |
||
18 | |||
19 | 6 | $keys = []; |
|
20 | 6 | $values = []; |
|
21 | |||
22 | 6 | foreach ($iterable as $key => $value) { |
|
23 | 5 | $keys[] = $key; |
|
24 | 5 | $values[] = $value; |
|
25 | } |
||
26 | |||
27 | 6 | return compact('keys', 'values'); |
|
28 | } |
||
29 |