Completed
Push — cs ( 9c9fc7...96045f )
by Akihito
02:05
created

ReflectionClass::setObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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 2
    public function setObject(WeavedInterface $object)
18
    {
19 2
        $this->object = $object;
20 2
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 2
    public function getAnnotations() : array
26
    {
27
        /** @var AbstractWeave $object */
28 2
        $object = $this->object;
29
30 2
        return unserialize($object->classAnnotations);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 2
    public function getAnnotation(string $annotationName)
37
    {
38 2
        $annotations = $this->getAnnotations();
39 2
        foreach ($annotations as $annotation) {
40 1
            if ($annotation instanceof $annotationName) {
41 1
                return $annotation;
42
            }
43
        }
44 1
    }
45
}
46