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

NetteReflectionEngine   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
eloc 11
c 2
b 0
f 1
dl 0
loc 20
rs 10
ccs 10
cts 10
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAnnotation() 0 8 2
A hasAnnotation() 0 8 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