Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Worksheet; 4 5 use PhpOffice\PhpSpreadsheet\Spreadsheet; 6 7 class Iterator implements \Iterator 8 { 9 /** 10 * Spreadsheet to iterate. 11 * 12 * @var Spreadsheet 13 */ 14 private $subject; 15 16 /** 17 * Current iterator position. 18 * 19 * @var int 20 */ 21 private $position = 0; 22 23 /** 24 * Create a new worksheet iterator. 25 */ 26 public function __construct(Spreadsheet $subject) 27 { 28 // Set subject 29 $this->subject = $subject; 30 } 31 32 /** 33 * Destructor. 34 */ 35 public function __destruct() 36 { 37 $this->subject = null; 38 } 39 40 /** 41 * Rewind iterator. 42 */ 43 public function rewind(): void 44 { 45 $this->position = 0; 46 } 47 48 /** 49 * Current Worksheet. 50 * 51 * @return Worksheet 52 */ 53 public function current() 54 { 55 return $this->subject->getSheet($this->position); 56 } 57 58 /** 59 * Current key. 60 * 61 * @return int 62 */ 63 public function key() 64 { 65 return $this->position; 66 } 67 68 /** 69 * Next value. 70 */ 71 public function next(): void 72 { 73 ++$this->position; 74 } 75 76 /** 77 * Are there more Worksheet instances available? 78 * 79 * @return bool 80 */ 81 public function valid() 82 { 83 return $this->position < $this->subject->getSheetCount() && $this->position >= 0; 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body