* @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 * * @throws InvalidSignatureException * @throws MissingSignatureException * @throws \OutOfBoundsException */ public function createProxy($instanceOrClassName) : RemoteObjectInterface { $proxyClassName = $this->generateProxy( is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName ); return $proxyClassName::staticProxyConstructor($this->adapter); } /** * {@inheritDoc} */ protected function getGenerator() : ProxyGeneratorInterface { return $this->generator ?: $this->generator = new RemoteObjectGenerator(); } }