src/Router.php
/**
     * Matches the set of route definitions to provided parameters.
     * @param array[] $routes The list of route definitions
     * @param string $method The request method or empty string for any
     * @param string[] $params The parameters from the path
     * @return null|Route The matched route or null if none matches
     */
Matches the set of route definitions to provided parameters.
@param array[] $routes The list of route definitions
@param string $method The request method or empty string for any
@param string[] $params The parameters from the path
@return null|Route The matched route or null if none matches
Matches the set of route definitions to provided parameters . @param array [] $routes The list of route definitions @param string $method The request method or empty string for any @param string [] $params The parameters from the path @return null|Route The matched route or null if none matches
private function matchRoutes(array $routes, $method, array $params)
    {
        $params = array_values($params);
        $method = strtoupper((string) $method);
        foreach ($routes as $route) {
            if (count($params) !== count($route['params'])) {
                continue;
            } elseif ($method && !in_array($method, $route['methods'])) {
                continue;
            }
            foreach (array_values($route['params']) as $i => $regexp) {
                if (!preg_match($regexp, $params[$i])) {
                    continue;
                }
            }
            $values = array_combine(array_keys($route['params']), $params);
            $values = array_filter($values, 'is_string', ARRAY_FILTER_USE_KEY);
            return new Route($route, $method, $values);
        }
        return null;
    }
private function matchRoutes ( array $ routes , $ method , array $ params ) { $ params = array_values ( $ params ) ; $ method = strtoupper ( ( string ) $ method ) ; foreach ( $ routes as $ route ) { if ( count ( $ params ) !== count ( $ route [ 'params' ] ) ) { continue ; } elseif ( $ method && ! in_array ( $ method , $ route [ 'methods' ] ) ) { continue ; } foreach ( array_values ( $ route [ 'params' ] ) as $ i => $ regexp ) { if ( ! preg_match ( $ regexp , $ params [ $ i ] ) ) { continue ; } } $ values = array_combine ( array_keys ( $ route [ 'params' ] ) , $ params ) ; $ values = array_filter ( $ values , 'is_string' , ARRAY_FILTER_USE_KEY ) ; return new Route ( $ route , $ method , $ values ) ; } return null ; }
Matches the set of route definitions to provided parameters.
Matches the set of route definitions to provided parameters .