From 917ee42b2aa87ee85bb0303062a020e6def9fc43 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 19 May 2014 20:45:42 +0200 Subject: [PATCH] This method can be supported: - isStackEmpty() can use getStackCount() and compare it with zero. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../main/stacker/file/class_BaseFileStack.php | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 203655d9..58a41f46 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -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] -- 2.39.5