Completed
Push — master ( d10f54...00ced4 )
by
unknown
05:32
created

AnnotationMethodAnalyzer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A analyze() 0 18 4
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
use samsonframework\container\definition\MethodDefinition;
14
15
class AnnotationMethodAnalyzer extends AbstractAnnotationAnalyzer implements MethodAnalyzerInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     * @throws MethodDefinitionAlreadyExistsException
20
     */
21 2
    public function analyze(
22
        DefinitionAnalyzer $analyzer,
23
        \ReflectionMethod $reflectionMethod,
24
        ClassDefinition $classDefinition,
25
        MethodDefinition $methodDefinition = null
26
    ) {
27
        // Define property if not exists
28 2
        if (!$methodDefinition) {
29 2
            $methodDefinition = $classDefinition->defineMethod($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...
30
        }
31
        // Resolve annotations
32 2
        $annotations = $this->reader->getMethodAnnotations($reflectionMethod);
33 2
        foreach ($annotations as $annotation) {
34 2
            if ($annotation instanceof ResolveMethodInterface) {
35 2
                $annotation->resolveMethod($analyzer, $reflectionMethod, $classDefinition, $methodDefinition);
0 ignored issues
show
Compatibility introduced by
$methodDefinition of type object<samsonframework\c...MethodBuilderInterface> is not a sub-type of object<samsonframework\c...ition\MethodDefinition>. It seems like you assume a concrete implementation of the interface samsonframework\containe...\MethodBuilderInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
36
            }
37
        }
38 2
    }
39
}
40