Completed
Push — master ( d62d29...27939e )
by Marko
02:28
created

AnnotationReaderTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPropertyAnnotation() 0 3 1
A __construct() 0 3 1
A getClassAnnotations() 0 3 1
A getClassAnnotation() 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): ?AnnotationInterface
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 getPropertyAnnotation(\ReflectionProperty $property, string $annotation): ?AnnotationInterface
33
    {
34
        return $this->annotationReader->getPropertyAnnotation($property, $annotation);
35
    }
36
}
37