]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/database/result/class_CachedDatabaseResult.php
Rewrite:
[core.git] / framework / main / classes / database / result / class_CachedDatabaseResult.php
index 664270e653d7821513f33c1da6ea04e8e1a40cd9..98b7ad2e369dd7f60b31330f7e7294d548b7b8e3 100644 (file)
@@ -14,6 +14,7 @@ use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
 
 // Import SPL stuff
 use \InvalidArgumentException;
+use \OutOfBoundsException;
 use \SeekableIterator;
 
 /**
@@ -78,7 +79,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -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 ($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();
                }