kahlan\Expectation::__call PHP Method

__call() public method

Calls a registered matcher.
public __call ( string $matcherName, array $args ) : boolean
$matcherName string The name of the matcher.
$args array The arguments to pass to the matcher.
return boolean
    public function __call($matcherName, $args)
    {
        $result = true;
        $spec = $this->_actual;
        $this->_passed = true;
        $closure = function () use($spec, $matcherName, $args, &$actual, &$result) {
            if ($spec instanceof Specification) {
                $actual = null;
                if (!$spec->passed($actual)) {
                    return false;
                }
            } else {
                $actual = $spec;
            }
            array_unshift($args, $actual);
            $matcher = $this->_matcher($matcherName, $actual);
            $result = call_user_func_array($matcher . '::match', $args);
            return is_object($result) || $result === !$this->_not;
        };
        try {
            $this->_spin($closure);
        } catch (TimeoutException $e) {
            $data['data']['timeout'] = $e->getMessage();
        }
        array_unshift($args, $actual);
        $matcher = $this->_matcher($matcherName, $actual);
        $data = Inspector::parameters($matcher, 'match', $args);
        $report = compact('matcherName', 'matcher', 'data');
        if ($spec instanceof Specification) {
            foreach ($spec->logs() as $value) {
                $this->_logs[] = $value;
            }
            $this->_passed = $spec->passed() && $this->_passed;
        }
        if (!is_object($result)) {
            $report['description'] = $report['matcher']::description();
            $this->_log($result, $report);
            return $this;
        }
        $this->_deferred = $report + ['instance' => $result, 'not' => $this->_not];
        return $result;
    }