Skip to content

Commit be45d8e

Browse files
committed
Add each() pdb query helper.
1 parent 1a64df3 commit be45d8e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/PdbQuery.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
* - `keyed(): [key => object]`
7272
* - `iterator(): iterable<object>`
7373
* - `batch($size): iterable<object[]>`
74+
* - `each($size): iterable<object>`
7475
*
7576
* @package karmabunny\pdb
7677
*/
@@ -1050,6 +1051,24 @@ public function batch(int $size): Generator
10501051
}
10511052

10521053

1054+
/**
1055+
*
1056+
* @param int $size
1057+
* @return Generator
1058+
* @throws InvalidArgumentException
1059+
* @throws QueryException
1060+
* @throws ConnectionException
1061+
*/
1062+
public function each(int $size): Generator
1063+
{
1064+
foreach ($this->batch($size) as $results) {
1065+
foreach ($results as $result) {
1066+
yield $result;
1067+
}
1068+
}
1069+
}
1070+
1071+
10531072
/**
10541073
*
10551074
* @param array|string|null $key

0 commit comments

Comments
 (0)