Fixes and double->single converted
[core.git] / inc / classes / main / stacker / class_BaseStacker.php
index d86598233e7b4ab4aad67ee76e62e94dce8b3d88..40f7c0514d8e03867bde9debca0199a95441f7be 100644 (file)
@@ -28,11 +28,6 @@ class BaseStacker extends BaseFrameworkSystem {
        const EXCEPTION_NO_STACKER_FOUND            = 0x052;
        const EXCEPTION_STACKER_IS_EMPTY            = 0x053;
 
-       /**
-        * An array holding all stacks
-        */
-       private $stacks = array();
-
        /**
         * Protected constructor
         *
@@ -52,18 +47,15 @@ class BaseStacker extends BaseFrameworkSystem {
         * @return      void
         * @throws      AlreadyInitializedStackerException      If the stack is already initialized
         */
-       public final function initStacker ($stackerName, $forceReInit = false) {
+       public final function initStacker ($stackerName, $forceReInit = FALSE) {
                // Is the stack already initialized?
-               if (($forceReInit === false) && ($this->isStackInitialized($stackerName))) {
+               if (($forceReInit === FALSE) && ($this->isStackInitialized($stackerName))) {
                        // Then throw the exception
                        throw new AlreadyInitializedStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_ALREADY_INITIALIZED);
                } // END - if
 
                // Initialize the given stack
-               $this->stacks[$stackerName] = array(
-                       'max_size' => $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size'),
-                       'entries'  => array()
-               );
+               $this->pushValueToGenericArrayElement('stacks', $stackerName, 'max_size', $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size'));
        }
 
        /**
@@ -74,7 +66,7 @@ class BaseStacker extends BaseFrameworkSystem {
         */
        public final function isStackInitialized ($stackerName) {
                // Is is there?
-               $isInitialized = ((isset($this->stacks[$stackerName])) && (is_array($this->stacks[$stackerName])));
+               $isInitialized = ($this->isValidGenericArrayGroup('stacks', $stackerName));
 
                // Return result
                return $isInitialized;
@@ -137,7 +129,7 @@ class BaseStacker extends BaseFrameworkSystem {
                } // END - if
 
                // Now, count the array of entries
-               $count = count($this->stacks[$stackerName]['entries']);
+               $count = $this->countGenericArrayElements('stacks', $stackerName, 'entries');
 
                // Return result
                return $count;
@@ -162,7 +154,7 @@ class BaseStacker extends BaseFrameworkSystem {
                }
 
                // Now add the value to the stack
-               array_push($this->stacks[$stackerName]['entries'], $value);
+               $this->pushValueToGenericArrayElement('stacks', $stackerName, 'entries', $value);
        }
 
        /**
@@ -184,7 +176,7 @@ class BaseStacker extends BaseFrameworkSystem {
                }
 
                // Now get the last value
-               $value = $this->stacks[$stackerName]['entries'][$this->getStackCount($stackerName) - 1];
+               $value = $this->getGenericArrayKey('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1);
 
                // Return it
                return $value;
@@ -208,8 +200,8 @@ class BaseStacker extends BaseFrameworkSystem {
                        throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                }
 
-               // Now get the last value
-               $value = $this->stacks[$stackerName]['entries'][0];
+               // Now get the first value
+               $value = $this->getGenericArrayKey('stacks', $stackerName, 'entries', 0);
 
                // Return it
                return $value;
@@ -234,7 +226,7 @@ class BaseStacker extends BaseFrameworkSystem {
                }
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
-               array_pop($this->stacks[$stackerName]['entries']);
+               $this->popGenericArrayElement('stacks', $stackerName, 'entries');
        }
 
        /**
@@ -256,7 +248,7 @@ class BaseStacker extends BaseFrameworkSystem {
                }
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
-               array_shift($this->stacks[$stackerName]['entries']);
+               $this->shiftGenericArrayElement('stacks', $stackerName, 'entries');
        }
 }