Eloquent\Phony\Spy\SpyVerifierFactory::createGlobal PHP Method

createGlobal() public method

Create a new spy verifier for a global function and declare it in the specified namespace.
public createGlobal ( string $function, string $namespace ) : SpyVerifier
$function string The function name.
$namespace string The namespace.
return SpyVerifier The newly created spy verifier.
    public function createGlobal($function, $namespace)
    {
        if (false !== strpos($function, '\\')) {
            throw new InvalidArgumentException('Only functions in the global namespace are supported.');
        }
        $namespace = trim($namespace, '\\');
        if (!$namespace) {
            throw new InvalidArgumentException('The supplied namespace must not be empty.');
        }
        $spy = $this->spyFactory->create($function);
        $this->functionHookManager->defineFunction($function, $namespace, $spy);
        return new SpyVerifier($spy, $this->matcherFactory, $this->matcherVerifier, $this->generatorVerifierFactory, $this->iterableVerifierFactory, $this->callVerifierFactory, $this->assertionRecorder, $this->assertionRenderer);
    }