Eloquent\Phony\Mock\Handle\StaticHandle::proxy PHP Method

proxy() public method

This method may help when partial mocking of a particular implementation is not possible; as in the case of a final class.
public proxy ( object $object )
$object object The object to use.
    public function proxy($object)
    {
        $reflector = new ReflectionObject($object);
        foreach ($reflector->getMethods() as $method) {
            if (!$method->isStatic() || $method->isPrivate()) {
                continue;
            }
            $name = $method->getName();
            if ($this->class->hasMethod($name)) {
                $method->setAccessible(true);
                $this->stub($name)->doesWith(function ($arguments) use($method, $object) {
                    return $method->invokeArgs($object, $arguments->all());
                }, array(), false, true, false);
            }
        }
        return $this;
    }