X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fstacker%2Fclass_BaseStacker.php;h=a3419fe486db58647b1463e2b3eea823e44180db;hp=40f7c0514d8e03867bde9debca0199a95441f7be;hb=01cc80f06529313b40cb6858eae3f361c8ed1aee;hpb=89f25725096fa51850e2d4d0a2ed57906c0b23e0 diff --git a/inc/classes/main/stacker/class_BaseStacker.php b/inc/classes/main/stacker/class_BaseStacker.php index 40f7c051..a3419fe4 100644 --- a/inc/classes/main/stacker/class_BaseStacker.php +++ b/inc/classes/main/stacker/class_BaseStacker.php @@ -55,7 +55,7 @@ class BaseStacker extends BaseFrameworkSystem { } // END - if // Initialize the given stack - $this->pushValueToGenericArrayElement('stacks', $stackerName, 'max_size', $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size')); + $this->initGenericArrayKey('stacks', $stackerName, 'entries', $forceReInit); } /** @@ -66,7 +66,7 @@ class BaseStacker extends BaseFrameworkSystem { */ public final function isStackInitialized ($stackerName) { // Is is there? - $isInitialized = ($this->isValidGenericArrayGroup('stacks', $stackerName)); + $isInitialized = ($this->isValidGenericArrayKey('stacks', $stackerName, 'entries')); // Return result return $isInitialized; @@ -171,12 +171,12 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now get the last value - $value = $this->getGenericArrayKey('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1); + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1); // Return it return $value; @@ -196,12 +196,12 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now get the first value - $value = $this->getGenericArrayKey('stacks', $stackerName, 'entries', 0); + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0); // Return it return $value; @@ -211,7 +211,7 @@ class BaseStacker extends BaseFrameworkSystem { * "Pops" last entry from stack * * @param $stackerName Name of the stack - * @return void + * @return $value Value "poped" from array * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ @@ -221,19 +221,19 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above - $this->popGenericArrayElement('stacks', $stackerName, 'entries'); + return $this->popGenericArrayElement('stacks', $stackerName, 'entries'); } /** * "Pops" first entry from stack * * @param $stackerName Name of the stack - * @return void + * @return $value Value "shifted" from array * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ @@ -243,12 +243,12 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above - $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); + return $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); } }