[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/spout/src/Spout/Reader/CSV/ -> SheetIterator.php (source)

   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   * @package Box\Spout\Reader\CSV
  12   */
  13  class SheetIterator implements IteratorInterface
  14  {
  15      /** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
  16      protected $sheet;
  17  
  18      /** @var bool Whether the unique "sheet" has already been read */
  19      protected $hasReadUniqueSheet = false;
  20  
  21      /**
  22       * @param resource $filePointer
  23       * @param string $fieldDelimiter Character that delimits fields
  24       * @param string $fieldEnclosure Character that enclose fields
  25       * @param string $encoding Encoding of the CSV file to be read
  26       * @param \Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper
  27       */
  28      public function __construct($filePointer, $fieldDelimiter, $fieldEnclosure, $encoding, $endOfLineCharacter, $globalFunctionsHelper)
  29      {
  30          $this->sheet = new Sheet($filePointer, $fieldDelimiter, $fieldEnclosure, $encoding, $endOfLineCharacter, $globalFunctionsHelper);
  31      }
  32  
  33      /**
  34       * Rewind the Iterator to the first element
  35       * @link http://php.net/manual/en/iterator.rewind.php
  36       *
  37       * @return void
  38       */
  39      public function rewind()
  40      {
  41          $this->hasReadUniqueSheet = false;
  42      }
  43  
  44      /**
  45       * Checks if current position is valid
  46       * @link http://php.net/manual/en/iterator.valid.php
  47       *
  48       * @return boolean
  49       */
  50      public function valid()
  51      {
  52          return (!$this->hasReadUniqueSheet);
  53      }
  54  
  55      /**
  56       * Move forward to next element
  57       * @link http://php.net/manual/en/iterator.next.php
  58       *
  59       * @return void
  60       */
  61      public function next()
  62      {
  63          $this->hasReadUniqueSheet = true;
  64      }
  65  
  66      /**
  67       * Return the current element
  68       * @link http://php.net/manual/en/iterator.current.php
  69       *
  70       * @return \Box\Spout\Reader\CSV\Sheet
  71       */
  72      public function current()
  73      {
  74          return $this->sheet;
  75      }
  76  
  77      /**
  78       * Return the key of the current element
  79       * @link http://php.net/manual/en/iterator.key.php
  80       *
  81       * @return int
  82       */
  83      public function key()
  84      {
  85          return 1;
  86      }
  87  
  88      /**
  89       * Cleans up what was created to iterate over the object.
  90       *
  91       * @return void
  92       */
  93      public function end()
  94      {
  95          // do nothing
  96      }
  97  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1