public function route(Route $route, $http_method = self::METHOD_GET)
    {
        // Is this a valid HTTP method?
        if (!in_array($http_method, array(
            self::METHOD_HEAD,
            self::METHOD_GET,
            self::METHOD_POST,
            self::METHOD_PUT,
            self::METHOD_PATCH,
            self::METHOD_DELETE
        ))) {
            throw new \InvalidArgumentException("The method {$http_method} is invalid");
        }

        // Does this URL already exist in the routing table?
        if (isset($this->routes[$http_method][$route->pattern()])) {
            // Trigger a new error and exception if errors are on
            throw new \LogicException("The URI {$route->url()} already exists in the routing table");
        }

        // Add the route to the routing table
        $this->routes[$http_method][$route->pattern()] = $route;
    }
public function route(Route $route, $http_method = self::METHOD_GET)
    {
        // Is this a valid HTTP method?
        if (!in_array($http_method, array(
            self::METHOD_HEAD,
            self::METHOD_GET,
            self::METHOD_POST,
            self::METHOD_PUT,
            self::METHOD_PATCH,
            self::METHOD_DELETE
        ))) {
            throw new \InvalidArgumentException("The method {$http_method} is invalid");
        }

        // Does this URL already exist in the routing table?
        if (isset($this->routes[$http_method][$route->pattern()])) {
            // Trigger a new error and exception if errors are on
            throw new \LogicException("The URI {$route->url()} already exists in the routing table");
        }

        // Add the route to the routing table
        $this->routes[$http_method][$route->pattern()] = $route;
    }
public function route ( Route $ route , $ http_method = self :: METHOD_GET ) { // Is this a valid HTTP method? if ( ! in_array ( $ http_method , array ( self :: METHOD_HEAD , self :: METHOD_GET , self :: METHOD_POST , self :: METHOD_PUT , self :: METHOD_PATCH , self :: METHOD_DELETE ) ) ) { throw new \ InvalidArgumentException ( "The method {$http_method} is invalid" ) ; } // Does this URL already exist in the routing table? if ( isset ( $ this -> routes [ $ http_method ] [ $ route -> pattern ( ) ] ) ) { // Trigger a new error and exception if errors are on throw new \ LogicException ( "The URI {$route->url()} already exists in the routing table" ) ; } // Add the route to the routing table $ this -> routes [ $ http_method ] [ $ route -> pattern ( ) ] = $ route ; }
Adds a new URL routing rule to the routing table, after converting any of
our special tokens into proper regular expressions.

@param  Route  $route
@param  string $http_method
@throws \InvalidArgumentException If an invalid HTTP method is specified
@throws \LogicException           If the route already exists in the routing table
Adds a new URL routing rule to the routing table after converting any of our special tokens into proper regular expressions .