Skip to content

Commit 6cfe695

Browse files
committed
add example with key
1 parent 84972c6 commit 6cfe695

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,10 @@ var_dump(Finder::rows(
350350
static fn ($datum): bool => $datum < 5,
351351
true
352352
)); // []
353+
354+
// WITH key array included, pass $key variable as 2nd arg on filter to be used in filter
355+
var_dump(Finder::rows(
356+
$data,
357+
static fn($datum, $key): bool => $datum > 6 && $key > 1
358+
)); // [8, 9]
353359
```

tests/FinderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ public static function rowsDataProvider(): array
271271
static fn($datum): bool => $datum > 6,
272272
[7, 8, 9],
273273
],
274+
[
275+
[6, 7, 8, 9],
276+
static fn($datum, $key): bool => $datum > 6 && $key > 1,
277+
[8, 9],
278+
],
274279
[
275280
[6, 7, 8, 9],
276281
static fn($datum): bool => $datum < 5,

0 commit comments

Comments
 (0)