protected function matchDynamicRoute(string $path, string $method): ? Route
    {
        // The route to return (null by default)
        $route = null;
        // The dynamic routes
        $dynamicRoutes = self::$collection->getDynamicRoutes($method);

        // Attempt to find a match using dynamic routes that are set
        foreach ($dynamicRoutes as $regex => $dynamicRoute) {
            // If the preg match is successful, we've found our route!
            /* @var array $matches */
            if (preg_match($regex, $path, $matches)) {
                $route = $this->getMatchedDynamicRoute($dynamicRoute, $matches, $method);

                break;
            }
        }

        // If the route was found and the method is valid
        if (null !== $route && $this->isValidMethod($route, $method)) {
            // Return the route
            return $route;
        }

        return null;
    }
protected function matchDynamicRoute(string $path, string $method): ? Route
    {
        // The route to return (null by default)
        $route = null;
        // The dynamic routes
        $dynamicRoutes = self::$collection->getDynamicRoutes($method);

        // Attempt to find a match using dynamic routes that are set
        foreach ($dynamicRoutes as $regex => $dynamicRoute) {
            // If the preg match is successful, we've found our route!
            /* @var array $matches */
            if (preg_match($regex, $path, $matches)) {
                $route = $this->getMatchedDynamicRoute($dynamicRoute, $matches, $method);

                break;
            }
        }

        // If the route was found and the method is valid
        if (null !== $route && $this->isValidMethod($route, $method)) {
            // Return the route
            return $route;
        }

        return null;
    }
protected function matchDynamicRoute ( string $ path , string $ method ) : ? Route { // The route to return (null by default) $ route = null ; // The dynamic routes $ dynamicRoutes = self :: $ collection -> getDynamicRoutes ( $ method ) ; // Attempt to find a match using dynamic routes that are set foreach ( $ dynamicRoutes as $ regex => $ dynamicRoute ) { // If the preg match is successful, we've found our route! /* @var array $matches */ if ( preg_match ( $ regex , $ path , $ matches ) ) { $ route = $ this -> getMatchedDynamicRoute ( $ dynamicRoute , $ matches , $ method ) ; break ; } } // If the route was found and the method is valid if ( null !== $ route && $ this -> isValidMethod ( $ route , $ method ) ) { // Return the route return $ route ; } return null ; }
Try to match a dynamic route by path and method.

@param string $path   The path
@param string $method The method

@return null|Route
The route if found or null when no static route is
found for the path and method combination specified
Try to match a dynamic route by path and method .