AbstractArgument.php
4 years ago
ArgumentInterface.php
4 years ago
BoundArgument.php
2 years ago
IteratorArgument.php
4 years ago
ReferenceSetArgumentTrait.php
4 years ago
RewindableGenerator.php
4 years ago
ServiceClosureArgument.php
4 years ago
ServiceLocator.php
2 years ago
ServiceLocatorArgument.php
4 years ago
TaggedIteratorArgument.php
2 years ago
index.php
3 years ago
RewindableGenerator.php
26 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\DependencyInjection\Argument; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class RewindableGenerator implements \IteratorAggregate, \Countable |
| 5 | { |
| 6 | private $generator; |
| 7 | private $count; |
| 8 | public function __construct(callable $generator, $count) |
| 9 | { |
| 10 | $this->generator = $generator; |
| 11 | $this->count = $count; |
| 12 | } |
| 13 | public function getIterator() : \Traversable |
| 14 | { |
| 15 | $g = $this->generator; |
| 16 | return $g(); |
| 17 | } |
| 18 | public function count() : int |
| 19 | { |
| 20 | if (\is_callable($count = $this->count)) { |
| 21 | $this->count = $count(); |
| 22 | } |
| 23 | return $this->count; |
| 24 | } |
| 25 | } |
| 26 |