Eloquent\Phony\Matcher\MatcherVerifier::explain PHP Метод

explain() публичный Метод

Explain which of the supplied arguments match which of the supplied matchers.
public explain ( array $matchers, array $arguments ) : MatcherResult
$matchers array
$arguments array The arguments.
Результат MatcherResult The result of matching.
    public function explain(array $matchers, array $arguments)
    {
        $isMatch = true;
        $matcherMatches = array();
        $argumentMatches = array();
        $pair = each($arguments);
        foreach ($matchers as $matcher) {
            if ($matcher instanceof WildcardMatcher) {
                $matcherIsMatch = true;
                $innerMatcher = $matcher->matcher();
                $minimumArguments = $matcher->minimumArguments();
                $maximumArguments = $matcher->maximumArguments();
                for ($count = 0; $count < $minimumArguments; ++$count) {
                    if (empty($pair)) {
                        $matcherIsMatch = false;
                        $argumentMatches[] = false;
                        break;
                    }
                    if ($innerMatcher->matches($pair[1])) {
                        $argumentMatches[] = true;
                    } else {
                        $matcherIsMatch = false;
                        $argumentMatches[] = false;
                    }
                    $pair = each($arguments);
                }
                if (null === $maximumArguments) {
                    while (!empty($pair) && $innerMatcher->matches($pair[1])) {
                        $argumentMatches[] = true;
                        $pair = each($arguments);
                    }
                } else {
                    for (; $count < $maximumArguments; ++$count) {
                        if (empty($pair) || !$innerMatcher->matches($pair[1])) {
                            break;
                        }
                        $argumentMatches[] = true;
                        $pair = each($arguments);
                    }
                }
                $isMatch = $isMatch && $matcherIsMatch;
                $matcherMatches[] = $matcherIsMatch;
                continue;
            }
            $matcherIsMatch = !empty($pair) && $matcher->matches($pair[1]);
            $isMatch = $isMatch && $matcherIsMatch;
            $matcherMatches[] = $matcherIsMatch;
            $argumentMatches[] = $matcherIsMatch;
            $pair = each($arguments);
        }
        while (!empty($pair)) {
            $argumentMatches[] = false;
            $isMatch = false;
            $pair = each($arguments);
        }
        return new MatcherResult($isMatch, $matcherMatches, $argumentMatches);
    }