diff --git a/src/Finder.php b/src/Finder.php index 926145a..dee410b 100644 --- a/src/Finder.php +++ b/src/Finder.php @@ -141,6 +141,7 @@ public static function rows( // filter must be a callable with bool return type Filter::boolean($filter); + Assert::nullOrPositiveInteger($limit); foreach ($data as $key => $datum) { $isFound = $filter($datum, $key); diff --git a/tests/FinderTest.php b/tests/FinderTest.php index fac445a..f348565 100644 --- a/tests/FinderTest.php +++ b/tests/FinderTest.php @@ -393,6 +393,9 @@ public function testRowsWithLimit(): void ], Finder::rows($data, $filter, limit: 1) ); + + $this->expectExceptionMessage('Expected a positive integer. Got: 0'); + Finder::rows($data, $filter, limit: 0); } /**