PrivatePropertiesMap   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
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 37
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 initializer for a lazy object
14
 */
15
class PrivatePropertiesMap 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('privateProperties')
28 4
        );
29 4
30
        $this->setVisibility(self::VISIBILITY_PRIVATE);
31
        $this->setStatic(true);
32 4
        $this->setDocBlock(
33 4
            '@var array[][] visibility and default value of defined properties, indexed by property name and class name'
34 4
        );
35 4
        $this->setDefaultValue($this->getMap($properties));
36
    }
37 4
38 4
    /**
39
     * @return array<string, array<class-string, bool>>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
40
     */
41
    private function getMap(Properties $properties) : array
42
    {
43
        $map = [];
44 4
45
        foreach ($properties->getPrivateProperties() as $property) {
46 4
            $map[$property->getName()][$property->getDeclaringClass()->getName()] = true;
47
        }
48 4
49 3
        return $map;
50
    }
51
}
52