[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Argument/ -> RewindableGenerator.php (source)

   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 int|callable $count
  24       */
  25      public function __construct(callable $generator, $count)
  26      {
  27          $this->generator = $generator;
  28          $this->count = $count;
  29      }
  30  
  31      public function getIterator()
  32      {
  33          $g = $this->generator;
  34  
  35          return $g();
  36      }
  37  
  38      public function count()
  39      {
  40          if (\is_callable($count = $this->count)) {
  41              $this->count = $count();
  42          }
  43  
  44          return $this->count;
  45      }
  46  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1