]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/database/result/class_CachedDatabaseResult.php
Refacuring / possible WIP:
[core.git] / framework / main / classes / database / result / class_CachedDatabaseResult.php
index 747660386c1e29384599f21e9ca3e84102d43e16..9b59813bb9da9944c34f184a42f549c20dbbf6c0 100644 (file)
@@ -14,6 +14,7 @@ use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
 
 // Import SPL stuff
 use \InvalidArgumentException;
+use \OutOfBoundsException;
 use \SeekableIterator;
 
 /**
@@ -171,15 +172,22 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul
        /**
         * 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();
                }