public function getCommand()
 {
     $request = $this->requestKnowledge->getRequest();
     $requestedRoute = $request->getUri()->getPath();
     $requestedMethod = $request->getMethod();
     $routeInfo = $this->dispatcher->dispatch($requestedMethod, $requestedRoute);
     switch ($routeInfo[0]) {
         case Dispatcher::NOT_FOUND:
             throw new NotFoundException('Route \'' . $requestedRoute . '\' with method \'' . $requestedMethod . '\' not found.');
         case Dispatcher::METHOD_NOT_ALLOWED:
             //$allowedMethods = $routeInfo[1];
             throw new MethodNotAllowedException('Method not allowed');
         case Dispatcher::FOUND:
             /** @var string $commandCreatorClass */
             $commandCreatorClass = $routeInfo[1];
             $sl = $this->serviceLocator;
             /** @var CommandCreatorInterface $commandCreator */
             $commandCreator = $sl($commandCreatorClass);
             /** @var string[] $vars */
             $vars = $routeInfo[2];
             $request = $request->withAttribute(RouterInterface::MATCHED_VARIABLES_ARRAY_KEY, $vars);
             $this->requestKnowledge->setRequest($request);
             return $commandCreator->createCommand($request);
         default:
             throw new Exception('Error in FastRoute!');
     }
 }
 public function run()
 {
     try {
         $requestWithParsedBody = $this->requestBodyParser->enrichRequestWithParsedBody($this->requestKnowledge->getRequest());
         $this->requestKnowledge->setRequest($requestWithParsedBody);
         $command = $this->router->getCommand();
         $this->commandBus->handle($command);
     } catch (HttpException $e) {
         $this->exceptionHandler->handle($e);
     }
 }