ReflectionMethodAnalyzer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A analyze() 0 17 4
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\MethodAnalyzerInterface;
11
use samsonframework\container\definition\ClassDefinition;
12
use samsonframework\container\definition\exception\MethodDefinitionAlreadyExistsException;
13
use samsonframework\container\definition\exception\MethodDefinitionNotFoundException;
14
15
/**
16
 * Class ReflectionMethodAnalyzer
17
 *
18
 * @author Ruslan Molodyko <[email protected]>
19
 */
20
class ReflectionMethodAnalyzer implements MethodAnalyzerInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     * @throws MethodDefinitionAlreadyExistsException
25
     * @throws MethodDefinitionNotFoundException
26
     */
27 4
    public function analyze(
28
        DefinitionAnalyzer $analyzer,
29
        ClassDefinition $classDefinition,
30
        \ReflectionMethod $reflectionMethod
31
    ) {
32 4
        $methodName = $reflectionMethod->getName();
0 ignored issues
show
Bug introduced by
Consider using $reflectionMethod->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
33
        // Constructor definition is required
34 4
        if ($methodName === '__construct' && !$classDefinition->hasMethod('__construct')) {
35 1
            $classDefinition->defineConstructor()->end();
36
        }
37
        // Set method metadata
38 4
        if ($classDefinition->hasMethod($methodName)) {
39 4
            $classDefinition->getMethod($methodName)
40 4
                ->setModifiers($reflectionMethod->getModifiers())
41 4
                ->setIsPublic($reflectionMethod->isPublic());
42
        }
43 4
    }
44
}
45