src/Plugin/Monkey.php
public static function patched($namespace, $className, $methodName, &$substitute = null)
    {
        $name = $className ?: $methodName;

        if ($namespace && ($className || function_exists("{$namespace}\\{$name}"))) {
            $name = "{$namespace}\\{$name}";
        }

        $method = isset(static::$_registered[$name]) ? static::$_registered[$name] : null;

        if (!$methodName) {
            $fake = $method ? $method->substitute() : null;
            if (is_object($fake)) {
                $substitute = $fake;
            }
            return $fake ?: $name;
        }

        if (!$method) {
            if (!Suite::registered($name)) {
                return $name;
            }
        } elseif ($method->actsAsAReplacement()) {
            return $method->closure();
        }

        return function () use ($name, $method) {
            $args = func_get_args();

            if (Suite::registered($name)) {
                Calls::log(null, compact('name', 'args'));
            }
            if ($method && $method->matchArgs($args)) {
                return $method($args);
            }
            return call_user_func_array($name, $args);
        };
    }
public static function patched($namespace, $className, $methodName, &$substitute = null)
    {
        $name = $className ?: $methodName;

        if ($namespace && ($className || function_exists("{$namespace}\\{$name}"))) {
            $name = "{$namespace}\\{$name}";
        }

        $method = isset(static::$_registered[$name]) ? static::$_registered[$name] : null;

        if (!$methodName) {
            $fake = $method ? $method->substitute() : null;
            if (is_object($fake)) {
                $substitute = $fake;
            }
            return $fake ?: $name;
        }

        if (!$method) {
            if (!Suite::registered($name)) {
                return $name;
            }
        } elseif ($method->actsAsAReplacement()) {
            return $method->closure();
        }

        return function () use ($name, $method) {
            $args = func_get_args();

            if (Suite::registered($name)) {
                Calls::log(null, compact('name', 'args'));
            }
            if ($method && $method->matchArgs($args)) {
                return $method($args);
            }
            return call_user_func_array($name, $args);
        };
    }
public static function patched ( $ namespace , $ className , $ methodName , & $ substitute = null ) { $ name = $ className ? : $ methodName ; if ( $ namespace && ( $ className || function_exists ( "{$namespace}\\{$name}" ) ) ) { $ name = "{$namespace}\\{$name}" ; } $ method = isset ( static :: $ _registered [ $ name ] ) ? static :: $ _registered [ $ name ] : null ; if ( ! $ methodName ) { $ fake = $ method ? $ method -> substitute ( ) : null ; if ( is_object ( $ fake ) ) { $ substitute = $ fake ; } return $ fake ? : $ name ; } if ( ! $ method ) { if ( ! Suite :: registered ( $ name ) ) { return $ name ; } } elseif ( $ method -> actsAsAReplacement ( ) ) { return $ method -> closure ( ) ; } return function ( ) use ( $ name , $ method ) { $ args = func_get_args ( ) ; if ( Suite :: registered ( $ name ) ) { Calls :: log ( null , compact ( 'name' , 'args' ) ) ; } if ( $ method && $ method -> matchArgs ( $ args ) ) { return $ method ( $ args ) ; } return call_user_func_array ( $ name , $ args ) ; } ; }
Patches the string.

@param  string $namespace  The namespace.
@param  string $className  The fully namespaced class reference string.
@param  string $methodName The method/function name.
@return string             A fully namespaced reference.
Patches the string .