protected function processRequest() { if (is_null($this->request)) { $this->request = $this->getNextRequest(); } if (!is_null($this->request)) { if ($this->atFloor($this->request->getFloor())) { $this->goingTarget = true; $this->go($this->request->getTarget()); } elseif ($this->goingTarget) { if ($this->atFloor($this->request->getTarget())) { $this->stop(); $this->request = null; $this->goingTarget = false; } } else { $this->goingTarget = false; $this->go($this->request->getFloor()); } } }
/** * @param Request $request * @return Elevator */ protected function pickAnElevator(Request $request) { return $this->getElevatorAtFloor($request->getFloor()) ?: ($this->getElevatorGoingToFloor($request->getFloor()) ?: $this->getStandingElevator()); }