kahlan\matcher\ToReceive::_check PHP Method

_check() protected method

Check the actual value can receive messages.
protected _check ( mixed $reference )
$reference mixed An instance or a fully-namespaced class name.
    protected function _check($reference)
    {
        $isString = is_string($reference);
        if ($isString) {
            if (!class_exists($reference)) {
                throw new InvalidArgumentException("Can't Spy the unexisting class `{$reference}`.");
            }
            $reflection = Inspector::inspect($reference);
        } else {
            $reflection = Inspector::inspect(get_class($reference));
        }
        if (!$reflection->isInternal()) {
            return;
        }
        if (!$isString) {
            throw new InvalidArgumentException("Can't Spy built-in PHP instances, create a test double using `Double::instance()`.");
        }
    }