Constructor   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 35
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 29 1
1
<?php
2
3
namespace Isolate\LazyObjects\Proxy\Adapter\OcramiusProxyManager\MethodGenerator;
4
5
use ProxyManager\Generator\MethodGenerator;
6
use ProxyManager\Generator\ParameterGenerator;
7
use ReflectionClass;
8
use ReflectionProperty;
9
use Zend\Code\Generator\PropertyGenerator;
10
11
class Constructor extends MethodGenerator
12
{
13
    /**
14
     * Constructor
15
     */
16
    public function __construct(
17
        ReflectionClass $originalClass,
18
        PropertyGenerator $wrappedObjectProperty,
19
        PropertyGenerator $lazyPropertiesProperty,
20
        PropertyGenerator $methodReplacementsProperty,
21
        PropertyGenerator $initializerProperty
22
    ) {
23
        parent::__construct('__construct');
24
25
        $lazyPropertiesArg = new ParameterGenerator('lazyProperties');
26
        $lazyPropertiesArg->setDefaultValue([]);
27
        $lazyPropertiesArg->setType('array');
28
29
        $methodReplacementsArg = new ParameterGenerator('methodReplacements');
30
        $methodReplacementsArg->setDefaultValue([]);
31
        $methodReplacementsArg->setType('array');
32
33
        $this->setParameter(new ParameterGenerator('wrappedObject'));
34
        $this->setParameter($lazyPropertiesArg);
35
        $this->setParameter($methodReplacementsArg);
36
37
        $this->setBody(
38
              '$this->' . $wrappedObjectProperty->getName() . " = \$wrappedObject;\n"
39
            . '$this->' . $lazyPropertiesProperty->getName() . " = \$lazyProperties;\n"
40
            . '$this->' . $methodReplacementsProperty->getName() . " = \$methodReplacements;\n"
41
            . '$this->' . $initializerProperty->getName() . " = new \\Isolate\\LazyObjects\\Object\\Property\\Initializer();\n"
42
            . '$this->' . $initializerProperty->getName() . "->initialize(\$this->" . $lazyPropertiesProperty->getName() . ", \"__construct\", \$this->" . $wrappedObjectProperty->getName() . ");\n"
43
        );
44
    }
45
}
46