public function getInfoAction()
 {
     $this->elevatorRepository = new ElevatorRepository("data/state");
     $this->elevator = $this->elevatorRepository->getElevator();
     try {
         $this->elevator->process();
         $this->elevatorRepository->saveElevator($this->elevator);
     } catch (Exception $e) {
     }
     $info = new \Lender411\ElevatorInfo($this->elevator);
     return json_encode(["description" => $info->getState(), "currentFloor" => $this->elevator->getCurrentFloor(), "targetFloor" => $this->elevator->getTargetFloor(), "state" => $this->elevator->getState()]);
 }
 /** @return array */
 public function addRequest(array $queue, Elevator $elevator, ElevatorRequest $request)
 {
     $this->queue = $queue;
     $this->elevator = $elevator;
     // Insert request which is currently handled by elevator (if any) into queue
     if ($elevator->hasCurrentRequest()) {
         array_unshift($this->queue, $elevator->getTargetFloor());
     }
     if ($request->getSourceFloor() === $request->getTargetFloor()) {
         // Ignore request from same floor
     } else {
         if (count($this->queue) === 0) {
             // If queue is empty, push requests directly into queue
             $this->queue = [$request->getSourceFloor(), $request->getTargetFloor()];
         } else {
             // If queue has some elements - put request into most appropriate place
             $this->route($request);
         }
     }
     return $this->queue;
 }