MagicClone   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator;
6
7
use Laminas\Code\Generator\PropertyGenerator;
8
use ProxyManager\Generator\MagicMethodGenerator;
9
use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator;
10
use ProxyManager\ProxyGenerator\Util\GetMethodIfExists;
11
use ReflectionClass;
12
13
/**
14
 * Magic `__clone` for lazy loading ghost objects
15
 */
16
class MagicClone extends MagicMethodGenerator
17
{
18
    /**
19
     * Constructor
20
     */
21
    public function __construct(
22
        ReflectionClass $originalClass,
23 2
        PropertyGenerator $prefixInterceptors,
24
        PropertyGenerator $suffixInterceptors
25
    ) {
26
        parent::__construct($originalClass, '__clone');
27
28 2
        $parent = GetMethodIfExists::get($originalClass, '__clone');
29
30 2
        $this->setBody(InterceptorGenerator::createInterceptedMethodBody(
31
            $parent ? '$returnValue = parent::__clone();' : '$returnValue = null;',
32 2
            $this,
33 2
            $prefixInterceptors,
34 2
            $suffixInterceptors,
35 2
            $parent
36 2
        ));
37 2
    }
38
}
39