ReflectionPropertyAnalyzer::analyze()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 3
crap 2
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by Ruslan Molodyko.
4
 * Date: 10.09.2016
5
 * Time: 15:33
6
 */
7
namespace samsonframework\container\definition\analyzer\reflection;
8
9
use samsonframework\container\definition\analyzer\DefinitionAnalyzer;
10
use samsonframework\container\definition\analyzer\PropertyAnalyzerInterface;
11
use samsonframework\container\definition\ClassDefinition;
12
use samsonframework\container\definition\exception\PropertyDefinitionNotFoundException;
13
14
/**
15
 * Class ReflectionPropertyAnalyzer
16
 *
17
 * @author Ruslan Molodyko <[email protected]>
18
 */
19
class ReflectionPropertyAnalyzer implements PropertyAnalyzerInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     * @throws PropertyDefinitionNotFoundException
24
     */
25 4
    public function analyze(
26
        DefinitionAnalyzer $analyzer,
27
        ClassDefinition $classDefinition,
28
        \ReflectionProperty $reflectionProperty
29
    ) {
30 4
        $propertyName = $reflectionProperty->getName();
31
        // Set property metadata
32 4
        if ($classDefinition->hasProperty($propertyName)) {
33 3
            $classDefinition->getProperty($propertyName)
34 3
                ->setIsPublic($reflectionProperty->isPublic())
35 3
                ->setModifiers($reflectionProperty->getModifiers());
36
        }
37 4
    }
38
}
39