4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Argument;
17 class RewindableGenerator implements \IteratorAggregate, \Countable
23 * @param callable $generator
24 * @param int|callable $count
26 public function __construct(callable $generator, $count)
28 $this->generator = $generator;
29 $this->count = $count;
32 public function getIterator()
34 $g = $this->generator;
39 public function count()
41 if (\is_callable($count = $this->count)) {
42 $this->count = $count();