for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace loophp\collection\Operation;
use Closure;
use Generator;
/**
* @immutable
*
* @template TKey
* @template T
*/
final class Group extends AbstractOperation
{
* @return Closure(iterable<TKey, T>): Generator<int, list<T>>
public function __invoke(): Closure
return
* @param iterable<TKey, T> $iterable
* @return Generator<int, list<T>>
static function (iterable $iterable): Generator {
$last = [];
foreach ($iterable as $current) {
if ([] === $last) {
$last = [$current];
continue;
}
if (current($last) === $current) {
$last[] = $current;
yield $last;
if ([] !== $last) {
};