public function callRequest(Route $route) { $route->setUrl($this->urlRequest); foreach ($route->getRoutes() as $url => $config) { if ($route->testEqualsUrl($url) and strtolower($_SERVER['REQUEST_METHOD']) == $config->type) { $class = "Younote\\Controllers\\{$config->class}"; if (class_exists($class)) { $controller = new $class(); $method = $config->method; if (!method_exists($controller, $method)) { echo 'ERROR: method not found'; } else { $this->setParam($url); new Response($controller->{$method}($this)); break; } } else { echo 'ERROR: class not found'; } } } }