src/Decorator/ProxyDecorator.php
protected function proxy()
    {
        $args = func_get_args();
        $method = array_shift($args);
        $callback = array($this->object, $method);

        if (!is_callable($callback)) {
            throw new \BadMethodCallException(
                sprintf(
                    'Cannot proxy "%s" to "%s": Unknown method.',
                    $method,
                    get_class($this->object)
                )
            );
        }

        $return = call_user_func_array($callback, $args);

        if ($return === $this->object) {
            // Return this decorator instead of the wrapped entity.
            $return = $this;
        }

        return $return;
    }
protected function proxy()
    {
        $args = func_get_args();
        $method = array_shift($args);
        $callback = array($this->object, $method);

        if (!is_callable($callback)) {
            throw new \BadMethodCallException(
                sprintf(
                    'Cannot proxy "%s" to "%s": Unknown method.',
                    $method,
                    get_class($this->object)
                )
            );
        }

        $return = call_user_func_array($callback, $args);

        if ($return === $this->object) {
            // Return this decorator instead of the wrapped entity.
            $return = $this;
        }

        return $return;
    }
protected function proxy ( ) { $ args = func_get_args ( ) ; $ method = array_shift ( $ args ) ; $ callback = array ( $ this -> object , $ method ) ; if ( ! is_callable ( $ callback ) ) { throw new \ BadMethodCallException ( sprintf ( 'Cannot proxy "%s" to "%s": Unknown method.' , $ method , get_class ( $ this -> object ) ) ) ; } $ return = call_user_func_array ( $ callback , $ args ) ; if ( $ return === $ this -> object ) { // Return this decorator instead of the wrapped entity. $ return = $ this ; } return $ return ; }
Proxies to the wrapped entity class.

The first argument must be the method name to proxy to, all further arguments
passed in are passed to the proxied method.

If the wrapped object returns itself, this method will return this decorator instead.

@return Decorator|mixed
@throws \BadMethodCallException If wrapped entity does not have the specified method.
Proxies to the wrapped entity class .