// Import SPL stuff
use \InvalidArgumentException;
+use \OutOfBoundsException;
use \SeekableIterator;
/**
/**
* Seeks for to a specified position
*
- * @param $index Index to seek for
+ * @param $seekPosition Position to seek to
* @return void
+ * @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $index) {
+ public function seek (int $seekPosition) {
+ // Validate parameter
+ if ($seekPosition < 0) {
+ // Throw exception
+ throw new OutOfBoundsException(sprintf('seekPositon=%d is not seekable', $seekPosition));
+ }
+
// Rewind to beginning
$this->rewind();
// Search for the entry
- while (($this->currentPos < $index) && ($this->valid())) {
+ while (($this->currentPos < $seekPosition) && ($this->valid())) {
// Continue on
$this->next();
}