Completed
Push — master ( d83119...6e6854 )
by Jakub
01:39
created

NetteReflectionEngine::hasAnnotation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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