Completed
Push — master ( 00ced4...d3edd8 )
by
unknown
07:54
created

AnnotationMethodAnalyzer::analyze()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 12
nc 7
nop 3
crap 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
class AnnotationMethodAnalyzer extends AbstractAnnotationAnalyzer implements MethodAnalyzerInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     * @throws MethodDefinitionAlreadyExistsException
19
     */
20 2
    public function analyze(
21
        DefinitionAnalyzer $analyzer,
22
        ClassDefinition $classDefinition,
23
        \ReflectionMethod $reflectionMethod
24
    ) {
25 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...
26
        // Resolve annotations
27 2
        $annotations = $this->reader->getMethodAnnotations($reflectionMethod);
28
        // Create method definition if annotation is exists
29 2
        if (count($annotations)) {
30
            // Define method if not exists
31 2
            if (!$classDefinition->hasMethod($methodName)) {
32 2
                $classDefinition->defineMethod($methodName);
33
            }
34
            // Exec method annotations
35 2
            foreach ($annotations as $annotation) {
36 2
                if ($annotation instanceof ResolveMethodInterface) {
37 2
                    $annotation->resolveMethod($analyzer, $classDefinition, $reflectionMethod);
38
                }
39
            }
40
        }
41 2
    }
42
}
43