Skip to content

Commit 93f3609

Browse files
committed
refactor: make if conditions simple
1 parent 828230b commit 93f3609

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

system/Helpers/array_helper.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ function dot_array_search(string $index, array $array)
4545
*/
4646
function _array_search_dot(array $indexes, array $array)
4747
{
48+
// If index is empty, returns null.
49+
if ($indexes === []) {
50+
return null;
51+
}
52+
4853
// Grab the current index
49-
$currentIndex = $indexes ? array_shift($indexes) : null;
50-
$intCurrentIndex = (int) $currentIndex;
54+
$currentIndex = array_shift($indexes);
5155

52-
if (empty($currentIndex) && $intCurrentIndex !== 0 || (! isset($array[$currentIndex]) && $currentIndex !== '*')) {
56+
if (! isset($array[$currentIndex]) && $currentIndex !== '*') {
5357
return null;
5458
}
5559

0 commit comments

Comments
 (0)