public function seek($position)
{
if ($this->iterator instanceof \SeekableIterator) {
try {
$this->iterator->seek($position);
} catch (\OutOfBoundsException $e) {
// Skipped on purpose, I don't think it's necessary
// If you'd like to have this exception throw, remove this try-catch and add to 'else' block
// If (!$this->valid()) { throw new \OutOfBoundsException('Invalid seek position'); };
}
} else {
$this->rewind();
for ($i = 0; $i < $position; $i++) {
$this->next();
}
}
}