This method can be supported:
authorRoland Haeder <roland@mxchange.org>
Mon, 19 May 2014 18:45:42 +0000 (20:45 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 19 May 2014 18:48:12 +0000 (20:48 +0200)
- isStackEmpty() can use getStackCount() and compare it with zero.

Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/stacker/file/class_BaseFileStack.php

index 203655d95b3c3c07a8fb37064eb81ec9d674ba2c..58a41f461ab16be461f9779a44039b24fd14c019 100644 (file)
@@ -423,12 +423,14 @@ class BaseFileStack extends BaseStacker {
         * @param       $stackerName    Name of the stack
         * @param       $value                  Value to add to this stacker
         * @return      void
+        * @throws      FullStackerException    If the stack is full
         */
        protected function addValue ($stackerName, $value) {
-               } elseif ($this->isStackFull($stackerName)) {
+               // Do some tests
+               if ($this->isStackFull($stackerName)) {
                        // Stacker is full
                        throw new FullStackerException(array($this, $stackerName, $value), self::EXCEPTION_STACKER_IS_FULL);
-               }
+               } // END - if
 
                // Now add the value to the stack
                $this->partialStub('stackerName=' . $stackerName . ',value[]=' . gettype($value));
@@ -439,13 +441,14 @@ class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
+        * @throws      EmptyStackerException   If the stack is empty
         */
        protected function getLastValue ($stackerName) {
                // Is the stack not yet initialized or full?
-               } elseif ($this->isStackEmpty($stackerName)) {
+               if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
                        throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
-               }
+               } // END - if
 
                // Now get the last value
                $this->partialStub('stackerName=' . $stackerName);
@@ -460,13 +463,14 @@ class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
+        * @throws      EmptyStackerException   If the stack is empty
         */
        protected function getFirstValue ($stackerName) {
                // Is the stack not yet initialized or full?
-               } elseif ($this->isStackEmpty($stackerName)) {
+               if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
                        throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
-               }
+               } // END - if
 
                // Now get the first value
                $this->partialStub('stackerName=' . $stackerName);
@@ -481,13 +485,14 @@ class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value "poped" from array
+        * @throws      EmptyStackerException   If the stack is empty
         */
        protected function popLast ($stackerName) {
                // Is the stack not yet initialized or full?
-               } elseif ($this->isStackEmpty($stackerName)) {
+               if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
                        throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
-               }
+               } // END - if
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
                $this->partialStub('stackerName=' . $stackerName);
@@ -499,15 +504,14 @@ class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value "shifted" from array
-        * @throws      NoStackerException      If the named stacker was not found
         * @throws      EmptyStackerException   If the named stacker is empty
         */
        protected function popFirst ($stackerName) {
                // Is the stack not yet initialized or full?
-               } elseif ($this->isStackEmpty($stackerName)) {
+               if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
                        throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
-               }
+               } // END - if
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
                $this->partialStub('stackerName=' . $stackerName);
@@ -561,17 +565,6 @@ class BaseFileStack extends BaseStacker {
                // Return result
                return $count;
        }
-
-       /**
-        * Checks whether the given stack is empty
-        *
-        * @param       $stackerName            Name of the stack
-        * @return      $isEmpty                        Whether the stack is empty
-        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
-        */
-       public final function isStackEmpty ($stackerName) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
 }
 
 // [EOF]