public static function matchRouteCollection(
        RouteCollectionInterface $routeCollection,
        ServerRequestInterface $request,
        $pathOffset,
        array $parentParams
    ) {
        $methodFailureResult = null;
        $schemeFailureResult = null;

        foreach ($routeCollection as $name => $route) {
            if (null === ($matchResult = $route->match($request, $pathOffset))) {
                continue;
            }

            if ($matchResult->isSuccess()) {
                return MatchResult::fromChildMatch($matchResult, $parentParams, $name);
            }

            if ($matchResult->isMethodFailure()) {
                if (null === $methodFailureResult) {
                    $methodFailureResult = $matchResult;
                } else {
                    $methodFailureResult = MatchResult::mergeMethodFailures($methodFailureResult, $matchResult);
                }
                continue;
            }

            if ($matchResult->isSchemeFailure()) {
                $schemeFailureResult = $schemeFailureResult ?: $matchResult;
                continue;
            }

            return $matchResult;
        }

        if (null !== $schemeFailureResult) {
            return $schemeFailureResult;
        }

        if (null !== $methodFailureResult) {
            return $methodFailureResult;
        }

        return null;
    }
public static function matchRouteCollection(
        RouteCollectionInterface $routeCollection,
        ServerRequestInterface $request,
        $pathOffset,
        array $parentParams
    ) {
        $methodFailureResult = null;
        $schemeFailureResult = null;

        foreach ($routeCollection as $name => $route) {
            if (null === ($matchResult = $route->match($request, $pathOffset))) {
                continue;
            }

            if ($matchResult->isSuccess()) {
                return MatchResult::fromChildMatch($matchResult, $parentParams, $name);
            }

            if ($matchResult->isMethodFailure()) {
                if (null === $methodFailureResult) {
                    $methodFailureResult = $matchResult;
                } else {
                    $methodFailureResult = MatchResult::mergeMethodFailures($methodFailureResult, $matchResult);
                }
                continue;
            }

            if ($matchResult->isSchemeFailure()) {
                $schemeFailureResult = $schemeFailureResult ?: $matchResult;
                continue;
            }

            return $matchResult;
        }

        if (null !== $schemeFailureResult) {
            return $schemeFailureResult;
        }

        if (null !== $methodFailureResult) {
            return $methodFailureResult;
        }

        return null;
    }
public static function matchRouteCollection ( RouteCollectionInterface $ routeCollection , ServerRequestInterface $ request , $ pathOffset , array $ parentParams ) { $ methodFailureResult = null ; $ schemeFailureResult = null ; foreach ( $ routeCollection as $ name => $ route ) { if ( null === ( $ matchResult = $ route -> match ( $ request , $ pathOffset ) ) ) { continue ; } if ( $ matchResult -> isSuccess ( ) ) { return MatchResult :: fromChildMatch ( $ matchResult , $ parentParams , $ name ) ; } if ( $ matchResult -> isMethodFailure ( ) ) { if ( null === $ methodFailureResult ) { $ methodFailureResult = $ matchResult ; } else { $ methodFailureResult = MatchResult :: mergeMethodFailures ( $ methodFailureResult , $ matchResult ) ; } continue ; } if ( $ matchResult -> isSchemeFailure ( ) ) { $ schemeFailureResult = $ schemeFailureResult ? : $ matchResult ; continue ; } return $ matchResult ; } if ( null !== $ schemeFailureResult ) { return $ schemeFailureResult ; } if ( null !== $ methodFailureResult ) { return $ methodFailureResult ; } return null ; }
Matches a request against a route collection.

@param  RouteCollectionInterface $routeCollection
@param  ServerRequestInterface   $request
@param  int                      $pathOffset
@param  array                    $parentParams
@return MatchResult|null
@throws UnexpectedValueException
Matches a request against a route collection .