Completed
Push — master ( 8f61de...6beb52 )
by Vitaly
02:52
created

AnnotationMethodResolver   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 12 2
A resolveMethodAnnotations() 0 9 3
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 07.08.16 at 13:04
5
 */
6
namespace samsonframework\container\annotation;
7
8
use samsonframework\container\configurator\MethodConfiguratorInterface;
9
use samsonframework\container\metadata\ClassMetadata;
10
use samsonframework\container\metadata\MethodMetadata;
11
use samsonframework\container\resolver\MethodResolverTrait;
12
13
/**
14
 * Class method annotation resolver.
15
 */
16
class AnnotationMethodResolver extends AbstractAnnotationResolver implements AnnotationResolverInterface
17
{
18
    use MethodResolverTrait;
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 11
    public function resolve(\ReflectionClass $classReflection, ClassMetadata $classMetadata)
24
    {
25
        /** @var \ReflectionMethod $method */
26 11
        foreach ($classReflection->getMethods() as $method) {
27 10
            $this->resolveMethodAnnotations(
28
                $method,
29 10
                $this->resolveMethodMetadata($method, $classMetadata)
30
            );
31
        }
32
33 11
        return $classMetadata;
34
    }
35
36
    /**
37
     * Resolve class method annotations.
38
     *
39
     * @param \ReflectionMethod $method
40
     * @param MethodMetadata    $methodMetadata
41
     */
42 10
    protected function resolveMethodAnnotations(\ReflectionMethod $method, MethodMetadata $methodMetadata)
43
    {
44
        /** @var MethodConfiguratorInterface $annotation */
45 10
        foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
46 10
            if ($annotation instanceof MethodConfiguratorInterface) {
47 10
                $annotation->toMethodMetadata($methodMetadata);
48
            }
49
        }
50 10
    }
51
}
52