/** * Find and dispatch a route based on the request http method and uri. * * @param string $method The HTTP method of the request, that should be GET, POST, PUT, PATCH or DELETE. * @param string $uri The URi of request. * @param bool $quiet Should throw exception on match errors? * * @return mixed The request response */ public function dispatch($method, $uri, $quiet = false) { $method = strtoupper($method); $path = $this->getUrlPath($uri); if ($route = $this->collection->getStaticRoute($method, $path)) { return $this->getStrategy($route['strategy'])->dispatch($route['action'], []); } if ($route = $this->matchDinamicRoute($this->collection->getCompiledDinamicRoutes($method), $path)) { return $this->getStrategy($route['strategy'])->dispatch($this->resolveDinamicRouteAction($route['action'], $route['params']), []); } if ($quiet === true) { return false; } $this->dispatchNotFoundRoute($method, $path); }