src/Spy/SpyVerifierFactory.php
public function createGlobal(
        string $function,
        string $namespace
    ): SpyVerifier {
        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
        );
    }
public function createGlobal(
        string $function,
        string $namespace
    ): SpyVerifier {
        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
        );
    }
public function createGlobal ( string $ function , string $ namespace ) : SpyVerifier { 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 ) ; }
Create a new spy verifier for a global function and declare it in the
specified namespace.

@param string $function  The function name.
@param string $namespace The namespace.

@return SpyVerifier              The newly created spy verifier.
@throws InvalidArgumentException If an invalid function name or namespace is specified.
Create a new spy verifier for a global function and declare it in the specified namespace .