Completed
Push — master ( 019907...013ee6 )
by Vitaly
03:05
created

AnnotationResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 45
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A resolve() 0 16 1
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 07.08.16 at 13:32
5
 */
6
namespace samsonframework\container\annotation;
7
8
use samsonframework\container\metadata\ClassMetadata;
9
use samsonframework\container\resolver\ResolverInterface;
10
11
/**
12
 * Annotation resolver implementation.
13
 *
14
 * @author Vitaly Iegorov <[email protected]>
15
 */
16
class AnnotationResolver implements ResolverInterface
17
{
18
    /** @var AnnotationResolverInterface */
19
    protected $classResolver;
20
21
    /** @var AnnotationResolverInterface */
22
    protected $propertyResolver;
23
24
    /** @var AnnotationResolverInterface */
25
    protected $methodResolver;
26
27
    /**
28
     * AnnotationResolver constructor.
29
     *
30
     * @param AnnotationResolverInterface $classResolver
31
     * @param AnnotationResolverInterface $propertyResolver
32
     * @param AnnotationResolverInterface $methodResolver
33
     */
34 11
    public function __construct(AnnotationResolverInterface $classResolver, AnnotationResolverInterface $propertyResolver, AnnotationResolverInterface $methodResolver)
35
    {
36 11
        $this->classResolver = $classResolver;
37 11
        $this->propertyResolver = $propertyResolver;
38 11
        $this->methodResolver = $methodResolver;
39 11
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 11
    public function resolve($classData, string $identifier = null) : ClassMetadata
45
    {
46
        /** @var \ReflectionClass $classData */
47
48
        // Create and fill class metadata base fields
49 11
        $classMetadata = new ClassMetadata();
50
51
        // Resolve class definition annotations
52 11
        $this->classResolver->resolve($classData, $classMetadata);
53
        // Resolve class properties annotations
54 11
        $this->propertyResolver->resolve($classData, $classMetadata);
55
        // Resolve class methods annotations
56 11
        $this->methodResolver->resolve($classData, $classMetadata);
57
58 11
        return $classMetadata;
59
    }
60
}
61