Conditions | 5 |
Paths | 5 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | 29 | public static function arrayRecursiveSearchKeyMap(mixed $needle, array $haystack): array|null |
|
10 | { |
||
11 | /** @psalm-suppress MixedAssignment */ |
||
12 | 29 | foreach ($haystack as $firsLevelKey => $value) { |
|
13 | 29 | if ($needle === $value) { |
|
14 | 18 | return array($firsLevelKey); |
|
15 | 28 | } elseif (is_array($value)) { |
|
16 | 28 | $callback = self::arrayRecursiveSearchKeyMap($needle, $value); |
|
17 | 28 | if ($callback) { |
|
18 | 15 | return array_merge(array($firsLevelKey), $callback); |
|
19 | } |
||
20 | } |
||
21 | } |
||
22 | 23 | return null; |
|
23 | } |
||
25 |