kahlan\Expectation::_matcher PHP Метод

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

Returns a compatible matcher class name according to a passed actual value.
public _matcher ( string $matcherName, mixed $actual ) : string
$matcherName string The name of the matcher.
$actual mixed The actual value.
Результат string A matcher class name.
    public function _matcher($matcherName, $actual)
    {
        if (!Matcher::exists($matcherName, true)) {
            throw new Exception("Unexisting matcher attached to `'{$matcherName}'`.");
        }
        $matcher = null;
        foreach (Matcher::get($matcherName, true) as $target => $value) {
            if (!$target) {
                $matcher = $value;
                continue;
            }
            if ($actual instanceof $target) {
                $matcher = $value;
            }
        }
        if (!$matcher) {
            throw new Exception("Unexisting matcher attached to `'{$matcherName}'` for `{$target}`.");
        }
        return $matcher;
    }