Passed
Pull Request — 1.x (#9)
by Marko
02:32
created

AnnotationReaderTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 27
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getClassAnnotations() 0 3 1
A getClassAnnotation() 0 3 1
A getMethodAnnotation() 0 3 1
A getPropertyAnnotations() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use Doctrine\Common\Annotations\Reader;
8
use KunicMarko\SonataAnnotationBundle\Annotation\AnnotationInterface;
9
10
/**
11
 * @author Marko Kunic <[email protected]>
12
 */
13
trait AnnotationReaderTrait
14
{
15
    private $annotationReader;
16
17
    public function __construct(Reader $annotationReader)
18
    {
19
        $this->annotationReader = $annotationReader;
20
    }
21
22
    protected function getClassAnnotation(\ReflectionClass $class, string $annotation)
23
    {
24
        return $this->annotationReader->getClassAnnotation($class, $annotation);
25
    }
26
27
    protected function getClassAnnotations(\ReflectionClass $class): array
28
    {
29
        return $this->annotationReader->getClassAnnotations($class);
30
    }
31
32
    protected function getPropertyAnnotations(\ReflectionProperty $property): array
33
    {
34
        return $this->annotationReader->getPropertyAnnotations($property);
35
    }
36
37
    protected function getMethodAnnotation(\ReflectionMethod $method, string $annotation)
38
    {
39
        return $this->annotationReader->getMethodAnnotation($method, $annotation);
40
    }
41
}
42