* @license MIT */ class RemoteObjectFactory extends AbstractBaseFactory { /** * @var AdapterInterface */ protected $adapter; /** * @var \ProxyManager\ProxyGenerator\RemoteObjectGenerator|null */ private $generator; /** * {@inheritDoc} * * @param AdapterInterface $adapter * @param Configuration $configuration */ public function __construct(AdapterInterface $adapter, Configuration $configuration = null) { parent::__construct($configuration); $this->adapter = $adapter; } /** * @param string|object $instanceOrClassName * * @return \ProxyManager\Proxy\RemoteObjectInterface */ public function createProxy($instanceOrClassName) { $className = is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName; $proxyClassName = $this->generateProxy($className); return new $proxyClassName($this->adapter); } /** * {@inheritDoc} */ protected function getGenerator() { return $this->generator ?: $this->generator = new RemoteObjectGenerator(); } }