for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace loophp\iterators;
use Closure;
use Generator;
use IteratorAggregate;
* @template TKey
* @template T
* @template W
*
* @implements IteratorAggregate<TKey, W>
final class MapIterableAggregate implements IteratorAggregate
{
* @param iterable<TKey, T> $iterable
* @param (Closure(T, TKey, iterable<TKey, T>): W) $closure
(Closure(T, TKey, iterable<TKey, T>): W)
1
public function __construct(private iterable $iterable, private Closure $closure)
}
* @return Generator<TKey, W>
public function getIterator(): Generator
foreach ($this->iterable as $key => $value) {
yield $key => ($this->closure)($value, $key, $this->iterable);