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

ReflectionClass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 39
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setObject() 0 4 1
A getAnnotations() 0 7 1
A getAnnotation() 0 9 3
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