1 <?php 2 3 declare(strict_types=1); 4 5 namespace OpenSpout\Reader\CSV; 6 7 use OpenSpout\Reader\SheetIteratorInterface; 8 9 /** 10 * @implements SheetIteratorInterface<Sheet> 11 */ 12 final class SheetIterator implements SheetIteratorInterface 13 { 14 /** @var Sheet The CSV unique "sheet" */ 15 private Sheet $sheet; 16 17 /** @var bool Whether the unique "sheet" has already been read */ 18 private bool $hasReadUniqueSheet = false; 19 20 /** 21 * @param Sheet $sheet Corresponding unique sheet 22 */ 23 public function __construct(Sheet $sheet) 24 { 25 $this->sheet = $sheet; 26 } 27 28 /** 29 * Rewind the Iterator to the first element. 30 * 31 * @see http://php.net/manual/en/iterator.rewind.php 32 */ 33 public function rewind(): void 34 { 35 $this->hasReadUniqueSheet = false; 36 } 37 38 /** 39 * Checks if current position is valid. 40 * 41 * @see http://php.net/manual/en/iterator.valid.php 42 */ 43 public function valid(): bool 44 { 45 return !$this->hasReadUniqueSheet; 46 } 47 48 /** 49 * Move forward to next element. 50 * 51 * @see http://php.net/manual/en/iterator.next.php 52 */ 53 public function next(): void 54 { 55 $this->hasReadUniqueSheet = true; 56 } 57 58 /** 59 * Return the current element. 60 * 61 * @see http://php.net/manual/en/iterator.current.php 62 */ 63 public function current(): Sheet 64 { 65 return $this->sheet; 66 } 67 68 /** 69 * Return the key of the current element. 70 * 71 * @see http://php.net/manual/en/iterator.key.php 72 */ 73 public function key(): int 74 { 75 return 1; 76 } 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body