public function addRoute(Route $route): void
    {
        $key                = md5(\json_encode((array) $route));
        $this->routes[$key] = $route;

        foreach ($route->getRequestMethods() as $requestMethod) {
            // If this is a dynamic route
            if ($route->isDynamic()) {
                // Set the route's regex and path in the dynamic routes list
                $this->dynamicRoutes[$requestMethod][$route->getRegex()] = $key;
            } // Otherwise set it in the static routes array
            else {
                // Set the route's path in the static routes list
                $this->staticRoutes[$requestMethod][$route->getPath()] = $key;
            }
        }

        // If this route has a name set
        if ($route->getName()) {
            // Set the route in the named routes list
            $this->namedRoutes[$route->getName()] = $key;
        }
    }
public function addRoute(Route $route): void
    {
        $key                = md5(\json_encode((array) $route));
        $this->routes[$key] = $route;

        foreach ($route->getRequestMethods() as $requestMethod) {
            // If this is a dynamic route
            if ($route->isDynamic()) {
                // Set the route's regex and path in the dynamic routes list
                $this->dynamicRoutes[$requestMethod][$route->getRegex()] = $key;
            } // Otherwise set it in the static routes array
            else {
                // Set the route's path in the static routes list
                $this->staticRoutes[$requestMethod][$route->getPath()] = $key;
            }
        }

        // If this route has a name set
        if ($route->getName()) {
            // Set the route in the named routes list
            $this->namedRoutes[$route->getName()] = $key;
        }
    }
public function addRoute ( Route $ route ) : void { $ key = md5 ( \ json_encode ( ( array ) $ route ) ) ; $ this -> routes [ $ key ] = $ route ; foreach ( $ route -> getRequestMethods ( ) as $ requestMethod ) { // If this is a dynamic route if ( $ route -> isDynamic ( ) ) { // Set the route's regex and path in the dynamic routes list $ this -> dynamicRoutes [ $ requestMethod ] [ $ route -> getRegex ( ) ] = $ key ; } // Otherwise set it in the static routes array else { // Set the route's path in the static routes list $ this -> staticRoutes [ $ requestMethod ] [ $ route -> getPath ( ) ] = $ key ; } } // If this route has a name set if ( $ route -> getName ( ) ) { // Set the route in the named routes list $ this -> namedRoutes [ $ route -> getName ( ) ] = $ key ; } }
Add a route.

@param Route $route The route

@return void
Add a route .