/** * Add an executable in the tier it wants to be run in, or the * next stage if no tier is set. * @param Executable $executable * @throws TierException */ public function addExecutable(Executable $executable) { $tierNumber = $executable->getTierNumber(); $nextStage = $this->currentTier + 1; if ($tierNumber === null) { $tierNumber = $nextStage; } if ($tierNumber < $this->currentTier) { $message = sprintf("Cannot add executable to tier %d as current tier is %d", $tierNumber, $this->currentTier); throw new TierException($message, TierException::INCORRECT_VALUE); } $this->addExecutableToTier($tierNumber, $executable); }