Completed
Push — master ( c8c0c1...47af09 )
by Jakub
01:44
created

NetteReflectionEngine::hasAnnotation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 5
c 2
b 0
f 1
dl 0
loc 8
rs 10
ccs 5
cts 5
cp 1
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MyTester\Annotations;
6
7
use Nette\Reflection\ClassType;
8
use Nette\Reflection\Method;
9
10
/**
11
 * Nette Reflection engine for annotations reader
12
 *
13
 * @author Jakub Konečný
14
 * @internal
15
 */
16
final class NetteReflectionEngine implements \MyTester\IAnnotationsReaderEngine
17
{
18 1
    public function hasAnnotation(string $name, $class, string $method = null): bool
19
    {
20 1
        if ($method !== null) {
21 1
            $reflection = new Method($class, $method);
22
        } else {
23 1
            $reflection = ClassType::from($class);
24
        }
25 1
        return $reflection->hasAnnotation($name);
26
    }
27
28 1
    public function getAnnotation(string $name, $class, string $method = null)
29
    {
30 1
        if ($method !== null) {
31 1
            $reflection = new Method($class, $method);
32
        } else {
33 1
            $reflection = ClassType::from($class);
34
        }
35 1
        return $reflection->getAnnotation($name);
36
    }
37
}
38