@param Enum  $enum
@param Match $match

@return Matcher
185926
private function whenMatch(Enum $enum, Match $match)
    {
        if (!$enum instanceof $this->subject) {
            $classSubject  = get_class($this->subject);
            $classArgument = get_class($enum);

            throw new InvalidArgumentException(
                "This map is already mapping an instance of {$classSubject}, " .
                "yet this invocation is trying to map an instance of {$classArgument}."
            );
        }

        if (array_key_exists($enum->getName(), $this->matches)) {
            throw new InvalidArgumentException(
                "This map has already mapped instance {$enum} to a value."
            );
        }

        /** @noinspection PhpInternalEntityUsedInspection */
        $this->matches[$enum->getName()] = $match;

        return $this;
    }
766355
public function enum($column, $enumName = null, $locale = null)
    {
        return $this->__($column, $enumName, $locale);
    }
802677
public function matchHost($pattern, &$matches = null, $flags = 0, $offset = 0)
	{
		return preg_match($pattern, $this->_host ?: '', $matches, $flags, $offset);
	}
70631
public static function reduce(array $carry, Match $match)
    {
        if (!isset($carry[$match->index]) || $carry[$match->index]->score < $match->score) {
            $carry[$match->index] = $match;
        }

        return $carry;
    }
393480
protected function normalizeMatches($matches)
    {
        return collect($matches)
            ->filter(function ($item, $key) {
                return ! is_numeric($key);
            })
            ->map(function ($item, $key) {
                $return = $item[0];

                if (starts_with($key, 'load')) {
                    $return = floatval($return);
                } elseif (is_numeric($return)) {
                    $return = (int) $return;
                } elseif (empty($return)) {
                    $return = null;
                }

                return $return;
            })
            ->toArray();
    }
1236976
public function validateEnum(Model $model, $check, $rule) {
        $field = key($check);
        $value = $check[$field];

        if ($value === '' || $value === null || $value === false) {
            return (bool) $rule['allowEmpty'];
        }

        $enum = $this->enum($model, $field);

        return isset($enum[$value]);
    }
1078946
public function create($request, $match)
    {
        $receipt = Bank_Service::create($request, $request->REQUEST);
        return $receipt;
    }
424071
public function match() : Stage\Match
    {
        $stage = new Stage\Match($this);
        $this->addStage($stage);

        return $stage;
    }
1169172
protected function status($match = null)
    {
        $status = isset($this->status[0]) ? $this->status[0] : null;

        if ($match !== null) {
            return $status === $match;
        }

        return $status;
    }
282665
protected function createController(Match $match) : ControllerInterface
	{
		// TODO: Use dependency magic to create the controller instance
		/** @var ControllerInterface $controller */
		$controller = new $match->controller();
		$controller->setRouteParams($match->parameters);

		return $controller;
	}
41078
protected function compileStatement(array $match)
    {
        if (strpos($match[1], '@') !== false) {
            $match[0] = isset($match[3]) ? $match[1] . $match[3] : $match[1];
        } elseif (isset($this->directives[$match[1]])) {
            $match[0] = call_user_func($this->directives[$match[1]], isset($match[3]) ? $match[3] : null);
        } elseif (method_exists($this, $method = 'compile' . ucfirst($match[1]))) {
            $match[0] = $this->$method(isset($match[3]) ? $match[3] : null);
        }

        return isset($match[3]) ? $match[0] : $match[0] . $match[2];
    }
307526
public function explain(array $matchers, array $arguments): MatcherResult
    {
        $isMatch = true;
        $matcherMatches = [];
        $argumentMatches = [];
        $argumentCount = count($arguments);
        $index = 0;

        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 ($index >= $argumentCount) {
                        $matcherIsMatch = false;
                        $argumentMatches[] = false;

                        break;
                    }

                    if ($innerMatcher->matches($arguments[$index])) {
                        $argumentMatches[] = true;
                    } else {
                        $matcherIsMatch = false;
                        $argumentMatches[] = false;
                    }

                    ++$index;
                }

                if ($maximumArguments < 0) {
                    while (
                        $index < $argumentCount &&
                        $innerMatcher->matches($arguments[$index])
                    ) {
                        $argumentMatches[] = true;
                        ++$index;
                    }
                } else {
                    for (; $count < $maximumArguments; ++$count) {
                        if (
                            $index >= $argumentCount ||
                            !$innerMatcher->matches($arguments[$index])
                        ) {
                            break;
                        }

                        $argumentMatches[] = true;
                        ++$index;
                    }
                }

                $isMatch = $isMatch && $matcherIsMatch;
                $matcherMatches[] = $matcherIsMatch;

                continue;
            }

            $matcherIsMatch =
                $index < $argumentCount &&
                $matcher->matches($arguments[$index]);

            $isMatch = $isMatch && $matcherIsMatch;
            $matcherMatches[] = $matcherIsMatch;
            $argumentMatches[] = $matcherIsMatch;
            ++$index;
        }

        for (; $index < $argumentCount; ++$index) {
            $argumentMatches[] = false;
            $isMatch = false;
        }

        return new MatcherResult($isMatch, $matcherMatches, $argumentMatches);
    }
1337278
public function matchAction($matchAction = null)
    {
        if ($matchAction === null) {
            return $this->_matchAction;
        }
        $this->_matchAction = $matchAction;

        return $this;
    }
554485
public static function Match ($pattern, $subject, array &$matches = array(), $flags = 0, $offset = 0, $from_encoding = Encoding::DEFAULT_ENCODING) {
		return Regex::match($pattern, $subject, $matches, $flags, $offset, $from_encoding);
	}
692518
private function setEnum(string $enum): self
    {
        $this->updatePropertyValue(
            EnumFieldInterface::PROP_ENUM,
            $enum
        );

        return $this;
    }
430191
protected function matchRangeToken($i, $match, array &$matches, &$special, &$replace)
    {
        if (' - ' === $match) {
            $matches[$i - 1] = '>='.str_replace(array('*', 'x', 'X'), '0', $matches[$i - 1]);

            if (false !== strpos($matches[$i + 1], '.') && false === strpos($matches[$i + 1], '*')
                    && false === strpos($matches[$i + 1], 'x') && false === strpos($matches[$i + 1], 'X')) {
                $matches[$i] = ',<=';
            } else {
                $matches[$i] = ',<';
                $special = ',<~';
            }
        } else {
            $this->matchRangeTokenStep2($i, $match, $matches, $special, $replace);
        }
    }
914980
public function matchPath($pattern, &$matches = null, $flags = 0, $offset = 0)
	{
		return preg_match($pattern, $this->_path ?: '', $matches, $flags, $offset);
	}