true)); * $server->setObject($proxy); * * @param string $className name of the handling class to proxy. * @param array $classArgs arguments used to instantiate the handling class. * @param array $options proxy options. */ public function __construct($className, $classArgs = array(), $options = array()) { $class = new ReflectionClass($className); $constructor = $class->getConstructor(); if ($constructor === null) { $this->_classInstance = $class->newInstance(); } else { $this->_classInstance = $class->newInstanceArgs($classArgs); } $this->_className = $className; $this->_setOptions($options); } protected function _setOptions($options) { foreach ($options as $key => $value) { switch ($key) { case 'wrappedParts': $this->_wrappedParts = $value; break; default: break; } } } protected function _getOptions() { $options = array(); $options['wrappedParts'] = $this->_wrappedParts; return $options; } protected function _preProcessArguments($name, $arguments) { if ($this->_wrappedParts && count($arguments) == 1 && is_object($arguments[0])) { return get_object_vars($arguments[0]); } else { return $arguments; } } protected function _preProcessResult($name, $result) { if ($this->_wrappedParts) { return array($name.'Result' => $result); } else { return $result; } } public function __call($name, $arguments) { $result = call_user_func_array(array($this->_classInstance, $name), $this->_preProcessArguments($name, $arguments)); return $this->_preProcessResult($name, $result); } }