/** * Initializes controller and checks if target method is callable * @throws InvalidRouteException */ private function initController() { $fullClassName = $this->route->getControllerClass(); $methodName = $this->route->getControllerMethod(); if (!class_exists($fullClassName)) { throw new InvalidRouteException('Controller class does not exist: ' . $fullClassName); } $this->controller = new $fullClassName(); if (!method_exists($this->controller, $methodName)) { throw new InvalidRouteException('Controller method does not exist: ' . $methodName); } }