/** * Search a set of routes for the route matching a method and URI. * * @return Route */ public function route() { // Check for a literal route match first. If we find one, there is // no need to spin through all of the routes. if (isset($this->routes[$this->request])) { return Request::$route = new Route($this->request, $this->routes[$this->request]); } foreach ($this->routes as $keys => $callback) { // Only check routes that have multiple URIs or wildcards. // Other routes would have been caught by the check for literal matches. if (strpos($keys, '(') !== false or strpos($keys, ',') !== false) { foreach (explode(', ', $keys) as $key) { if (preg_match('#^' . $this->translate_wildcards($key) . '$#', $this->request)) { return Request::$route = new Route($keys, $callback, $this->parameters($this->request, $key)); } } } } }