Skip to content

Commit

Permalink
Merge pull request #6645 from kenjis/refactor-_array_search_dot
Browse files Browse the repository at this point in the history
refactor: _array_search_dot() if conditions
  • Loading branch information
kenjis authored Oct 8, 2022
2 parents df0fa73 + 93f3609 commit 84aa31e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions system/Helpers/array_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ function dot_array_search(string $index, array $array)
*/
function _array_search_dot(array $indexes, array $array)
{
// If index is empty, returns null.
if ($indexes === []) {
return null;
}

// Grab the current index
$currentIndex = $indexes ? array_shift($indexes) : null;
$intCurrentIndex = (int) $currentIndex;
$currentIndex = array_shift($indexes);

if (empty($currentIndex) && $intCurrentIndex !== 0 || (! isset($array[$currentIndex]) && $currentIndex !== '*')) {
if (! isset($array[$currentIndex]) && $currentIndex !== '*') {
return null;
}

Expand Down

0 comments on commit 84aa31e

Please sign in to comment.