Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401]

   1  <?php
   2  
   3  namespace Box\Spout\Reader\CSV;
   4  
   5  use Box\Spout\Reader\IteratorInterface;
   6  
   7  /**
   8   * Class SheetIterator
   9   * Iterate over CSV unique "sheet".
  10   */
  11  class SheetIterator implements IteratorInterface
  12  {
  13      /** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
  14      protected $sheet;
  15  
  16      /** @var bool Whether the unique "sheet" has already been read */
  17      protected $hasReadUniqueSheet = false;
  18  
  19      /**
  20       * @param Sheet $sheet Corresponding unique sheet
  21       */
  22      public function __construct($sheet)
  23      {
  24          $this->sheet = $sheet;
  25      }
  26  
  27      /**
  28       * Rewind the Iterator to the first element
  29       * @see http://php.net/manual/en/iterator.rewind.php
  30       *
  31       * @return void
  32       */
  33      public function rewind()
  34      {
  35          $this->hasReadUniqueSheet = false;
  36      }
  37  
  38      /**
  39       * Checks if current position is valid
  40       * @see http://php.net/manual/en/iterator.valid.php
  41       *
  42       * @return bool
  43       */
  44      public function valid()
  45      {
  46          return (!$this->hasReadUniqueSheet);
  47      }
  48  
  49      /**
  50       * Move forward to next element
  51       * @see http://php.net/manual/en/iterator.next.php
  52       *
  53       * @return void
  54       */
  55      public function next()
  56      {
  57          $this->hasReadUniqueSheet = true;
  58      }
  59  
  60      /**
  61       * Return the current element
  62       * @see http://php.net/manual/en/iterator.current.php
  63       *
  64       * @return \Box\Spout\Reader\CSV\Sheet
  65       */
  66      public function current()
  67      {
  68          return $this->sheet;
  69      }
  70  
  71      /**
  72       * Return the key of the current element
  73       * @see http://php.net/manual/en/iterator.key.php
  74       *
  75       * @return int
  76       */
  77      public function key()
  78      {
  79          return 1;
  80      }
  81  
  82      /**
  83       * Cleans up what was created to iterate over the object.
  84       *
  85       * @return void
  86       */
  87      public function end()
  88      {
  89          // do nothing
  90      }
  91  }