public function match($path, RouteRequest $request = null)
    {
        $requestMethod = null;

        if ($request) {

            $requestMethod = self::convertRequestMethodConstant($request->getRequestMethod());

        } else if (isset($_SERVER['REQUEST_METHOD'])) {

            $requestMethod = self::convertRequestMethodConstant($_SERVER['REQUEST_METHOD']);

        }

        foreach ($this->routes as $route) {
            // If the route is using pcre pattern marching...
            if ($route[0]) {
                if (!preg_match($route[1], $path, $matches)) {
                    continue;
                }
                $route[3]['vars'] = $matches;

                // validate request method
                if (isset($route[3]['method']) && $route[3]['method'] != $requestMethod) {
                    continue;
                }
                if (isset($route[3]['domain']) && $route[3]['domain'] != $_SERVER['HTTP_HOST']) {
                    continue;
                }
                if (isset($route[3]['secure']) && $route[3]['secure'] && $_SERVER['HTTPS']) {
                    continue;
                }

                return $route;
            } else {
                // prefix match is used when expanding is not enabled.
                if ((
                        (is_int($route[2]) || $route[2] instanceof self || $route[2] instanceof \PHPSGI\App)
                        && strncmp($route[1], $path, strlen($route[1])) === 0
                    ) || $route[1] == $path) {
                    // validate request method
                    if (isset($route[3]['method']) && $route[3]['method'] != $requestMethod) {
                        continue;
                    }
                    if (isset($route[3]['domain']) && $route[3]['domain'] != $_SERVER['HTTP_HOST']) {
                        continue;
                    }
                    if (isset($route[3]['secure']) && $route[3]['secure'] && $_SERVER['HTTPS']) {
                        continue;
                    }

                    return $route;
                }
                continue;
            }
        }
    }
public function match($path, RouteRequest $request = null)
    {
        $requestMethod = null;

        if ($request) {

            $requestMethod = self::convertRequestMethodConstant($request->getRequestMethod());

        } else if (isset($_SERVER['REQUEST_METHOD'])) {

            $requestMethod = self::convertRequestMethodConstant($_SERVER['REQUEST_METHOD']);

        }

        foreach ($this->routes as $route) {
            // If the route is using pcre pattern marching...
            if ($route[0]) {
                if (!preg_match($route[1], $path, $matches)) {
                    continue;
                }
                $route[3]['vars'] = $matches;

                // validate request method
                if (isset($route[3]['method']) && $route[3]['method'] != $requestMethod) {
                    continue;
                }
                if (isset($route[3]['domain']) && $route[3]['domain'] != $_SERVER['HTTP_HOST']) {
                    continue;
                }
                if (isset($route[3]['secure']) && $route[3]['secure'] && $_SERVER['HTTPS']) {
                    continue;
                }

                return $route;
            } else {
                // prefix match is used when expanding is not enabled.
                if ((
                        (is_int($route[2]) || $route[2] instanceof self || $route[2] instanceof \PHPSGI\App)
                        && strncmp($route[1], $path, strlen($route[1])) === 0
                    ) || $route[1] == $path) {
                    // validate request method
                    if (isset($route[3]['method']) && $route[3]['method'] != $requestMethod) {
                        continue;
                    }
                    if (isset($route[3]['domain']) && $route[3]['domain'] != $_SERVER['HTTP_HOST']) {
                        continue;
                    }
                    if (isset($route[3]['secure']) && $route[3]['secure'] && $_SERVER['HTTPS']) {
                        continue;
                    }

                    return $route;
                }
                continue;
            }
        }
    }
public function match ( $ path , RouteRequest $ request = null ) { $ requestMethod = null ; if ( $ request ) { $ requestMethod = self :: convertRequestMethodConstant ( $ request -> getRequestMethod ( ) ) ; } else if ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) { $ requestMethod = self :: convertRequestMethodConstant ( $ _SERVER [ 'REQUEST_METHOD' ] ) ; } foreach ( $ this -> routes as $ route ) { // If the route is using pcre pattern marching... if ( $ route [ 0 ] ) { if ( ! preg_match ( $ route [ 1 ] , $ path , $ matches ) ) { continue ; } $ route [ 3 ] [ 'vars' ] = $ matches ; // validate request method if ( isset ( $ route [ 3 ] [ 'method' ] ) && $ route [ 3 ] [ 'method' ] != $ requestMethod ) { continue ; } if ( isset ( $ route [ 3 ] [ 'domain' ] ) && $ route [ 3 ] [ 'domain' ] != $ _SERVER [ 'HTTP_HOST' ] ) { continue ; } if ( isset ( $ route [ 3 ] [ 'secure' ] ) && $ route [ 3 ] [ 'secure' ] && $ _SERVER [ 'HTTPS' ] ) { continue ; } return $ route ; } else { // prefix match is used when expanding is not enabled. if ( ( ( is_int ( $ route [ 2 ] ) || $ route [ 2 ] instanceof self || $ route [ 2 ] instanceof \ PHPSGI \ App ) && strncmp ( $ route [ 1 ] , $ path , strlen ( $ route [ 1 ] ) ) === 0 ) || $ route [ 1 ] == $ path ) { // validate request method if ( isset ( $ route [ 3 ] [ 'method' ] ) && $ route [ 3 ] [ 'method' ] != $ requestMethod ) { continue ; } if ( isset ( $ route [ 3 ] [ 'domain' ] ) && $ route [ 3 ] [ 'domain' ] != $ _SERVER [ 'HTTP_HOST' ] ) { continue ; } if ( isset ( $ route [ 3 ] [ 'secure' ] ) && $ route [ 3 ] [ 'secure' ] && $ _SERVER [ 'HTTPS' ] ) { continue ; } return $ route ; } continue ; } } }
Find a matched route with the path constraint in the current mux object.

@param string       $path
@param RouteRequest $request

@return array
Find a matched route with the path constraint in the current mux object .