kahlan\matcher\ToReceive::__construct PHP Method

__construct() public method

Constructor
public __construct ( string | object $actual, string $expected )
$actual string | object A fully-namespaced class name or an object instance.
$expected string The expected method method name to be called.
    public function __construct($actual, $expected)
    {
        $this->_backtrace = Debugger::backtrace();
        if (is_string($actual)) {
            $actual = ltrim($actual, '\\');
        }
        $this->_check($actual);
        if (!$expected) {
            throw new InvalidArgumentException("Method name can't be empty.");
        }
        $names = is_array($expected) ? $expected : [$expected];
        $reference = $actual;
        if (count($names) > 1) {
            if (!Stub::registered(Suite::hash($reference))) {
                throw new InvalidArgumentException("Kahlan can't Spy chained methods on real PHP code, you need to Stub the chain first.");
            }
        }
        $reference = $this->_reference($reference);
        foreach ($names as $index => $name) {
            if (preg_match('/^::.*/', $name)) {
                $reference = is_object($reference) ? get_class($reference) : $reference;
            }
            $this->_expected[] = $name;
            $this->_messages[$name] = $this->_watch(new Message(['parent' => $this, 'reference' => $reference, 'name' => $name]));
            $reference = null;
        }
    }