Completed
Pull Request — master (#463)
by Alexander
30:17 queued 05:15
created

AnnotatedReflectionMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 37
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
/*
5
 * Go! AOP framework
6
 *
7
 * @copyright Copyright 2014, Lisachenko Alexander <[email protected]>
8
 *
9
 * This source file is subject to the license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Go\Aop\Support;
14
15
use Doctrine\Common\Annotations\Reader;
16
use Go\Core\AspectKernel;
17
use ReflectionMethod;
18
19
/**
20
 * Extended version of ReflectionMethod with annotation support
21
 */
22
class AnnotatedReflectionMethod extends ReflectionMethod implements AnnotationAccess
23
{
24
    /**
25
     * Annotation reader
26
     */
27
    private static ?Reader $annotationReader = null;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '?', expecting T_FUNCTION or T_CONST
Loading history...
28
29
    /**
30
     * Gets concrete annotation by name or null if the requested annotation does not exist.
31
     */
32
    public function getAnnotation(string $annotationName): ?object
33
    {
34
        return self::getReader()->getMethodAnnotation($this, $annotationName);
35
    }
36
37
    /**
38
     * Gets all annotations applied to the current item.
39
     */
40
    public function getAnnotations(): array
41
    {
42
        return self::getReader()->getMethodAnnotations($this);
43
    }
44
45
    /**
46
     * Returns an annotation reader
47
     */
48
    private static function getReader(): Reader
49
    {
50
        if (self::$annotationReader === null) {
51
            self::$annotationReader = AspectKernel::getInstance()->getContainer()->get('aspect.annotation.reader');
52
        }
53
54
        return self::$annotationReader;
55
    }
56
}
57