AnnotationMethodAnalyzer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 29
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B analyze() 0 22 5
1
<?php declare(strict_types=1);
0 ignored issues
show
Coding Style introduced by
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
/**
3
 * Created by Ruslan Molodyko.
4
 * Date: 10.09.2016
5
 * Time: 17:48
6
 */
7
namespace samsonframework\container\definition\analyzer\annotation;
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
14
/**
15
 * Class AnnotationMethodAnalyzer
16
 *
17
 * @author Ruslan Molodyko <[email protected]>
18
 */
19
class AnnotationMethodAnalyzer extends AbstractAnnotationAnalyzer implements MethodAnalyzerInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     * @throws MethodDefinitionAlreadyExistsException
24
     */
25 2
    public function analyze(
26
        DefinitionAnalyzer $analyzer,
27
        ClassDefinition $classDefinition,
28
        \ReflectionMethod $reflectionMethod
29
    ) {
30 2
        $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...
31
        // Resolve annotations
32 2
        $annotations = $this->reader->getMethodAnnotations($reflectionMethod);
33
        // Create method definition if annotation is exists
34 2
        if (count($annotations)) {
35
            // Define method if not exists
36 2
            if (!$classDefinition->hasMethod($methodName)) {
37 2
                $classDefinition->defineMethod($methodName);
38
            }
39
            // Exec method annotations
40 2
            foreach ($annotations as $annotation) {
41 2
                if ($annotation instanceof ResolveMethodInterface) {
42 2
                    $annotation->resolveMethod($analyzer, $classDefinition, $reflectionMethod);
43
                }
44
            }
45
        }
46 2
    }
47
}
48