/** * Check if there is a current element after calls to rewind() or next(). * Used to check if we've iterated to the end of the collection * * @return boolean FALSE if there's nothing more to iterate over */ public function valid() { if ($this->Handle) { return $this->Handle->valid(); } return false; }
/** * Method for SeekableIterator interface. Takes a posiiton and traverses the file to that position * The value can be retrieved with a `current()` call afterwards. * * @param int Position in file */ public function seek($Position) { if (!$this->Handle) { throw new OutOfBoundsException('SpreadsheetReader: No file opened'); } $CurrentIndex = $this->Handle->key(); if ($CurrentIndex != $Position) { if ($Position < $CurrentIndex || is_null($CurrentIndex) || $Position == 0) { $this->rewind(); } while ($this->Handle->valid() && $Position > $this->Handle->key()) { $this->Handle->next(); } if (!$this->Handle->valid()) { throw new OutOfBoundsException('SpreadsheetError: Position ' . $Position . ' not found'); } } return null; }