Completed
Push — cs ( 9c9fc7 )
by Akihito
01:43
created

ReflectionClass::getAnnotations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop;
6
7
class ReflectionClass extends \ReflectionClass implements Reader
8
{
9
    /**
10
     * @var WeavedInterface
11
     */
12
    private $object;
13
14
    /**
15
     * Set dependencies
16
     */
17
    public function setObject(WeavedInterface $object)
18
    {
19
        $this->object = $object;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getAnnotations() : array
26
    {
27
        /** @var AbstractWeave $object */
28
        $object = $this->object;
29
30
        return unserialize($object->classAnnotations);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getAnnotation(string $annotationName)
37
    {
38
        $annotations = $this->getAnnotations();
39
        foreach ($annotations as $annotation) {
40
            if ($annotation instanceof $annotationName) {
41
                return $annotation;
42
            }
43
        }
44
    }
45
}
46