MagicClone   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator;
6
7
use Laminas\Code\Generator\PropertyGenerator;
8
use ProxyManager\Generator\MagicMethodGenerator;
9
use ReflectionClass;
10
11
/**
12
 * Magic `__clone` for lazy loading value holder objects
13
 */
14
class MagicClone extends MagicMethodGenerator
15
{
16
    /**
17
     * Constructor
18
     */
19
    public function __construct(
20
        ReflectionClass $originalClass,
21 1
        PropertyGenerator $initializerProperty,
22
        PropertyGenerator $valueHolderProperty
23
    ) {
24
        parent::__construct($originalClass, '__clone');
25
26 1
        $initializer = $initializerProperty->getName();
27
        $valueHolder = $valueHolderProperty->getName();
28 1
29 1
        $this->setBody(
30
            '$this->' . $initializer . ' && $this->' . $initializer
31 1
            . '->__invoke($this->' . $valueHolder
32 1
            . ', $this, \'__clone\', array(), $this->' . $initializer . ');' . "\n\n"
33 1
            . '$this->' . $valueHolder . ' = clone $this->' . $valueHolder . ';'
34 1
        );
35 1
    }
36
}
37