src/Matcher.php
protected function buildGroup(array $routes)
    {
        $groupCount = (int) $map = $regex = [];

        foreach ($routes as $route) {
            $params           = $route->getParams();
            $paramsCount      = count($params);
            $groupCount       = max($groupCount, $paramsCount) + 1;
            $regex[]          = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1);
            $map[$groupCount] = $route;
        }

        return ["~^(?|" . implode("|", $regex) . ")$~", $map];
    }
protected function buildGroup(array $routes)
    {
        $groupCount = (int) $map = $regex = [];

        foreach ($routes as $route) {
            $params           = $route->getParams();
            $paramsCount      = count($params);
            $groupCount       = max($groupCount, $paramsCount) + 1;
            $regex[]          = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1);
            $map[$groupCount] = $route;
        }

        return ["~^(?|" . implode("|", $regex) . ")$~", $map];
    }
protected function buildGroup ( array $ routes ) { $ groupCount = ( int ) $ map = $ regex = [ ] ; foreach ( $ routes as $ route ) { $ params = $ route -> getParams ( ) ; $ paramsCount = count ( $ params ) ; $ groupCount = max ( $ groupCount , $ paramsCount ) + 1 ; $ regex [ ] = $ route -> getPattern ( ) . str_repeat ( "()" , $ groupCount - $ paramsCount - 1 ) ; $ map [ $ groupCount ] = $ route ; } return [ "~^(?|" . implode ( "|" , $ regex ) . ")$~" , $ map ] ; }
Group several dynamic routes patterns into one big regex and maps
the routes to the pattern positions in the big regex.

@param Route[] $routes
@return array
Group several dynamic routes patterns into one big regex and maps the routes to the pattern positions in the big regex .