protected function matchRoute($pathInfo, $method, $id)
    {
        $route = $this->compile($this->routes[$id]);

        // When $route['method'] is not provided, accepts all request methods
        if ($method && $route['method'] && !preg_match('#' . $route['method'] . '#i', $method)) {
            return false;
        }

        // Check if the route matches the path info
        if (!preg_match($route['regex'], $pathInfo, $matches)) {
            return false;
        }

        // Get params in the path info
        $parameters = array();
        foreach ($matches as $key => $parameter) {
            if (is_int($key)) {
                continue;
            }
            $parameters[$key] = $parameter;
        }

        $parameters += $route['defaults'];

        preg_match_all('#<([a-zA-Z0-9_]++)>#', $route['pattern'], $matches);
        foreach ($matches[1] as $key) {
            if (!array_key_exists($key, $parameters)) {
                $parameters[$key] = null;
            }
        }

        return array('_id' => $id) + $parameters;
    }
protected function matchRoute($pathInfo, $method, $id)
    {
        $route = $this->compile($this->routes[$id]);

        // When $route['method'] is not provided, accepts all request methods
        if ($method && $route['method'] && !preg_match('#' . $route['method'] . '#i', $method)) {
            return false;
        }

        // Check if the route matches the path info
        if (!preg_match($route['regex'], $pathInfo, $matches)) {
            return false;
        }

        // Get params in the path info
        $parameters = array();
        foreach ($matches as $key => $parameter) {
            if (is_int($key)) {
                continue;
            }
            $parameters[$key] = $parameter;
        }

        $parameters += $route['defaults'];

        preg_match_all('#<([a-zA-Z0-9_]++)>#', $route['pattern'], $matches);
        foreach ($matches[1] as $key) {
            if (!array_key_exists($key, $parameters)) {
                $parameters[$key] = null;
            }
        }

        return array('_id' => $id) + $parameters;
    }
protected function matchRoute ( $ pathInfo , $ method , $ id ) { $ route = $ this -> compile ( $ this -> routes [ $ id ] ) ; // When $route['method'] is not provided, accepts all request methods if ( $ method && $ route [ 'method' ] && ! preg_match ( '#' . $ route [ 'method' ] . '#i' , $ method ) ) { return false ; } // Check if the route matches the path info if ( ! preg_match ( $ route [ 'regex' ] , $ pathInfo , $ matches ) ) { return false ; } // Get params in the path info $ parameters = array ( ) ; foreach ( $ matches as $ key => $ parameter ) { if ( is_int ( $ key ) ) { continue ; } $ parameters [ $ key ] = $ parameter ; } $ parameters += $ route [ 'defaults' ] ; preg_match_all ( '#<([a-zA-Z0-9_]++)>#' , $ route [ 'pattern' ] , $ matches ) ; foreach ( $ matches [ 1 ] as $ key ) { if ( ! array_key_exists ( $ key , $ parameters ) ) { $ parameters [ $ key ] = null ; } } return array ( '_id' => $ id ) + $ parameters ; }
Check if the route matches the path info and method,
and return the parameters, or return false when not matched

@param  string      $pathInfo The path info to match
@param  string      $method The request method to match
@param  string      $id The id of the route
@return false|array
Check if the route matches the path info and method and return the parameters or return false when not matched