Completed
Push — multi ( fbc389...652b22 )
by Akihito
02:23
created

ReflectionClass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 43
ccs 12
cts 12
cp 1
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 11 3
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the Ray.Aop package.
6
 *
7
 * @license http://opensource.org/licenses/MIT MIT
8
 */
9
namespace Ray\Aop;
10
11
class ReflectionClass extends \ReflectionClass implements Reader
12
{
13
    /**
14
     * @var WeavedInterface
15
     */
16
    private $object;
17
18
    /**
19
     * Set dependencies
20
     *
21
     * @param WeavedInterface $object
22
     */
23 2
    public function setObject(WeavedInterface $object)
24
    {
25 2
        $this->object = $object;
26 2
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function getAnnotations() : array
32
    {
33
        /** @var AbstractWeave $object */
34 2
        $object = $this->object;
35
36 2
        return unserialize($object->classAnnotations);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 2
    public function getAnnotation(string $annotationName)
43
    {
44 2
        $annotations = $this->getAnnotations();
45 2
        foreach ($annotations as $annotation) {
46 1
            if ($annotation instanceof $annotationName) {
47 1
                return $annotation;
48
            }
49
        }
50
51 1
        return null;
52
    }
53
}
54