Completed
Push — master ( 3be072...ba2d3a )
by Marco
231:32 queued 209:55
created

src/ProxyManager/Factory/NullObjectFactory.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Factory;
6
7
use OutOfBoundsException;
8
use ProxyManager\Configuration;
9
use ProxyManager\Proxy\NullObjectInterface;
10
use ProxyManager\ProxyGenerator\NullObjectGenerator;
11
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
12
use ProxyManager\Signature\Exception\InvalidSignatureException;
13
use ProxyManager\Signature\Exception\MissingSignatureException;
14
use function get_class;
15
use function is_object;
16
17
/**
18
 * Factory responsible of producing proxy objects
19
 */
20
class NullObjectFactory extends AbstractBaseFactory
21
{
22
    private NullObjectGenerator $generator;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
23
24
    public function __construct(?Configuration $configuration = null)
25
    {
26
        parent::__construct($configuration);
27
28
        $this->generator = new NullObjectGenerator();
29
    }
30
31 2
    /**
32
     * @param object|string $instanceOrClassName the object to be wrapped or interface to transform to null object
33 2
     *
34 2
     * @throws InvalidSignatureException
35
     * @throws MissingSignatureException
36 2
     * @throws OutOfBoundsException
37
     */
38
    public function createProxy($instanceOrClassName) : NullObjectInterface
39
    {
40
        $className      = is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName;
41
        $proxyClassName = $this->generateProxy($className);
42 1
43
        return $proxyClassName::staticProxyConstructor();
44 1
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    protected function getGenerator() : ProxyGeneratorInterface
50
    {
51
        return $this->generator;
52
    }
53
}
54