arrHandlerQueue[$intPosition])) throw new \Exception("there is already a handler stored for position: $intPosition"); $this->arrHandlerQueue[$intPosition] = $cloHandler; ksort($this->arrHandlerQueue); } /** * @param $intPosition - the position the handler for deletion is stored under * * @throws UnexpectedParameterTypeException - if the parameter is not an integer * * delete the handler stored under the given position * **/ public function deleteHandler($intPosition) { if(!is_int($intPosition)) throw new UnexpectedParameterTypeException('integer', $intPosition); if(array_key_exists($intPosition, $this->arrHandlerQueue)) unset($this->arrHandlerQueue[$intPosition]); } /** * @returns (\DDDBL\Queue) - a clone of the queue-instance * * return a clone of the acutal queue * **/ public function getClone() { return clone $this; } /** * @param $arrParameter - the parameter to use when executing the queue-handler * * @returns (mixed) the state of "result" * * execute all handler in the queue, in the given * order from low to high. after execution return the * state "result". * * handler which generates an output * are expected to store the result in this state * **/ public function execute(array $arrParameter) { $this->getState()->add(array('result' => null)); foreach($this->arrHandlerQueue AS $cloHandler) $cloHandler($this, $arrParameter); return $this->getState()->get('result'); } /** * @returns (DataObject) - the DataObject which handles the states of the queue * * returns a reference to the DataObject, which * stores all states of the queue. * * if no object exists till now, a new one is created * **/ public function getState() { if(!is_object($this->objState)) $this->objState = new DataObject(); return $this->objState; } }