Completed
Push — 1.x ( c183a4...05b51a )
by Alexander
8s
created

AnnotatedReflectionMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 44
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAnnotation() 0 4 1
A getAnnotations() 0 4 1
A getReader() 0 8 2
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2014, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Aop\Support;
12
13
use Doctrine\Common\Annotations\Reader;
14
use Go\Core\AspectKernel;
15
use ReflectionMethod;
16
17
/**
18
 * Extended version of ReflectionMethod with annotation support
19
 */
20
class AnnotatedReflectionMethod extends ReflectionMethod
21
{
22
    /**
23
     * Annotation reader
24
     *
25
     * @var Reader
26
     */
27
    private static $annotationReader = null;
28
29
    /**
30
     * Gets a method annotation.
31
     *
32
     * @param string $annotationName The name of the annotation.
33
     * @return mixed The Annotation or NULL, if the requested annotation does not exist.
34
     */
35
    public function getAnnotation($annotationName)
36
    {
37
        return self::getReader()->getMethodAnnotation($this, $annotationName);
38
    }
39
40
    /**
41
     * Gets the annotations applied to a method.
42
     *
43
     * @return array An array of Annotations.
44
     */
45
    public function getAnnotations()
46
    {
47
        return self::getReader()->getMethodAnnotations($this);
48
    }
49
50
    /**
51
     * Returns an annotation reader
52
     *
53
     * @return Reader $reader
54
     */
55
    private static function getReader()
56
    {
57
        if (!self::$annotationReader) {
58
            self::$annotationReader = AspectKernel::getInstance()->getContainer()->get('aspect.annotation.reader');
59
        };
60
61
        return self::$annotationReader;
62
    }
63
}
64