Skip to content

Commit 51d3649

Browse files
refactoring dot notation
1 parent 43990b6 commit 51d3649

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/DotNotation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function unset_path(array &$haystack, string $path, string $separator = '.')
5656
$temp =& $haystack;
5757
while (count($keys) > 1) {
5858
$key = array_shift($keys);
59-
if (array_key_exists($key, $temp) and is_array($temp[$key])) {
59+
if (array_key_exists($key, $temp) && is_array($temp[$key])) {
6060
$temp =& $temp[$key];
6161
}
6262
}
@@ -73,13 +73,13 @@ function unset_path(array &$haystack, string $path, string $separator = '.')
7373
function has_path(array $haystack, string $path, string $separator = '.'): bool
7474
{
7575
$keys = explode($separator, $path);
76-
$target = $haystack;
77-
foreach ($keys as $innerKey) {
78-
if (! is_array($target) || ! array_key_exists($innerKey, $target)) {
76+
$temp = $haystack;
77+
foreach ($keys as $key) {
78+
if (! is_array($temp) || ! array_key_exists($key, $temp)) {
7979
return false;
8080
}
8181

82-
$target = $target[$innerKey];
82+
$temp = $temp[$key];
8383
}
8484

8585
return true;

0 commit comments

Comments
 (0)