Skip to content

Commit c9ea434

Browse files
committed
refactor: extract convertToArray()
1 parent ca717d1 commit c9ea434

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

system/Helpers/Array/ArrayHelper.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ final class ArrayHelper
2727
* @return array|bool|int|object|string|null
2828
*/
2929
public static function dotSearch(string $index, array $array)
30+
{
31+
return self::arraySearchDot(self::convertToArray($index), $array);
32+
}
33+
34+
private static function convertToArray(string $index)
3035
{
3136
// See https://regex101.com/r/44Ipql/1
3237
$segments = preg_split(
@@ -36,9 +41,10 @@ public static function dotSearch(string $index, array $array)
3641
PREG_SPLIT_NO_EMPTY
3742
);
3843

39-
$segments = array_map(static fn ($key) => str_replace('\.', '.', $key), $segments);
40-
41-
return self::arraySearchDot($segments, $array);
44+
return array_map(
45+
static fn ($key) => str_replace('\.', '.', $key),
46+
$segments
47+
);
4248
}
4349

4450
/**

0 commit comments

Comments
 (0)