Skip to content

Commit 3a5e5ca

Browse files
committed
No need convert to array for non-reverse order
1 parent 0df9752 commit 3a5e5ca

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Finder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public static function last(iterable $data, callable $filter): mixed
3636
*/
3737
private static function locateFirst(iterable $data, callable $filter, bool $isReverse = false): mixed
3838
{
39-
// convert to array if $data is Traversable
40-
if ($data instanceof Traversable) {
41-
$data = iterator_to_array($data);
42-
}
39+
if ($isReverse) {
40+
// convert to array if $data is Traversable
41+
if ($data instanceof Traversable) {
42+
$data = iterator_to_array($data);
43+
}
4344

44-
Assert::isArray($data);
45+
Assert::isArray($data);
4546

46-
if ($isReverse) {
4747
/** @var mixed[] $data */
4848
$data = array_reverse($data);
4949
}

0 commit comments

Comments
 (0)