ProtectedPropertiesMap   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A getMap() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator;
6
7
use Laminas\Code\Generator\Exception\InvalidArgumentException;
8
use Laminas\Code\Generator\PropertyGenerator;
9
use ProxyManager\Generator\Util\IdentifierSuffixer;
10
use ProxyManager\ProxyGenerator\Util\Properties;
11
12
/**
13
 * Property that contains the protected instance lazy-loadable properties of an object
14
 */
15
class ProtectedPropertiesMap extends PropertyGenerator
16
{
17
    public const KEY_DEFAULT_VALUE = 'defaultValue';
18
19
    /**
20
     * Constructor
21
     *
22
     * @throws InvalidArgumentException
23
     */
24
    public function __construct(Properties $properties)
25
    {
26 4
        parent::__construct(
27
            IdentifierSuffixer::getIdentifier('protectedProperties')
28 4
        );
29 4
30
        $this->setVisibility(self::VISIBILITY_PRIVATE);
31
        $this->setStatic(true);
32 4
        $this->setDocBlock(
33 4
            '@var string[][] declaring class name of defined protected properties, indexed by property name'
34 4
        );
35 4
        $this->setDefaultValue($this->getMap($properties));
36
    }
37 4
38 4
    /** @return string[] */
39
    private function getMap(Properties $properties) : array
40
    {
41 4
        $map = [];
42
43 4
        foreach ($properties->getProtectedProperties() as $property) {
44
            $map[$property->getName()] = $property->getDeclaringClass()->getName();
45 4
        }
46 3
47
        return $map;
48
    }
49
}
50