for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace ProxyManager\Factory;
use ProxyManager\Proxy\NullObjectInterface;
use ProxyManager\ProxyGenerator\NullObjectGenerator;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
use ProxyManager\Signature\Exception\InvalidSignatureException;
use ProxyManager\Signature\Exception\MissingSignatureException;
/**
* Factory responsible of producing proxy objects
*
* @author Vincent Blanchon <[email protected]>
* @license MIT
*/
class NullObjectFactory extends AbstractBaseFactory
{
* @var \ProxyManager\ProxyGenerator\NullObjectGenerator|null
private $generator;
* @param object|string $instanceOrClassName the object to be wrapped or interface to transform to null object
* @throws InvalidSignatureException
* @throws MissingSignatureException
* @throws \OutOfBoundsException
public function createProxy($instanceOrClassName) : NullObjectInterface
$className = is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName;
$proxyClassName = $this->generateProxy($className);
return $proxyClassName::staticProxyConstructor();
}
* {@inheritDoc}
protected function getGenerator() : ProxyGeneratorInterface
return $this->generator ?: $this->generator = new NullObjectGenerator();