Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Argument/RewindableGenerator.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\DependencyInjection\Argument; | |
13 | |
14 /** | |
15 * @internal | |
16 */ | |
17 class RewindableGenerator implements \IteratorAggregate, \Countable | |
18 { | |
19 private $generator; | |
20 private $count; | |
21 | |
22 /** | |
23 * @param callable $generator | |
24 * @param int|callable $count | |
25 */ | |
26 public function __construct(callable $generator, $count) | |
27 { | |
28 $this->generator = $generator; | |
29 $this->count = $count; | |
30 } | |
31 | |
32 public function getIterator() | |
33 { | |
34 $g = $this->generator; | |
35 | |
36 return $g(); | |
37 } | |
38 | |
39 public function count() | |
40 { | |
41 if (is_callable($count = $this->count)) { | |
42 $this->count = $count(); | |
43 } | |
44 | |
45 return $this->count; | |
46 } | |
47 } |