protected function getMatchedDynamicRoute(string $path, array $matches, string $method): Route
    {
        // Clone the route to avoid changing the one set in the master array
        $dynamicRoute = clone self::$collection->dynamicRoute($method, $path);
        // The first match is the path itself
        unset($matches[0]);

        // Iterate through the matches
        foreach ($matches as $key => $match) {
            // If there is no match (middle of regex optional group)
            if (! $match) {
                // Set the value to null so the controller's action
                // can use the default it sets
                $matches[$key] = null;
            }
        }

        // Set the matches
        $dynamicRoute->setMatches($matches);

        return $dynamicRoute;
    }
protected function getMatchedDynamicRoute(string $path, array $matches, string $method): Route
    {
        // Clone the route to avoid changing the one set in the master array
        $dynamicRoute = clone self::$collection->dynamicRoute($method, $path);
        // The first match is the path itself
        unset($matches[0]);

        // Iterate through the matches
        foreach ($matches as $key => $match) {
            // If there is no match (middle of regex optional group)
            if (! $match) {
                // Set the value to null so the controller's action
                // can use the default it sets
                $matches[$key] = null;
            }
        }

        // Set the matches
        $dynamicRoute->setMatches($matches);

        return $dynamicRoute;
    }
protected function getMatchedDynamicRoute ( string $ path , array $ matches , string $ method ) : Route { // Clone the route to avoid changing the one set in the master array $ dynamicRoute = clone self :: $ collection -> dynamicRoute ( $ method , $ path ) ; // The first match is the path itself unset ( $ matches [ 0 ] ) ; // Iterate through the matches foreach ( $ matches as $ key => $ match ) { // If there is no match (middle of regex optional group) if ( ! $ match ) { // Set the value to null so the controller's action // can use the default it sets $ matches [ $ key ] = null ; } } // Set the matches $ dynamicRoute -> setMatches ( $ matches ) ; return $ dynamicRoute ; }
Get a matched dynamic route.

@param string $path    The path
@param array  $matches The regex matches
@param string $method  The request method

@return \Valkyrja\Routing\Route
Get a matched dynamic route .