Total Complexity | 11 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
18 | final class PhpAttributesEngine implements \MyTester\IAnnotationsReaderEngine { |
||
19 | public function hasAnnotation(string $name, $class, string $method = null): bool { |
||
20 | if(!$this->isAvailable()) { |
||
21 | return false; |
||
22 | } |
||
23 | return count($this->getReflection($class, $method)->getAttributes($this->getClassName($name))) > 0; |
||
1 ignored issue
–
show
|
|||
24 | } |
||
25 | |||
26 | public function getAnnotation(string $name, $class, string $method = null) { |
||
27 | if(!$this->isAvailable()) { |
||
28 | return null; |
||
29 | } |
||
30 | $attributes = $this->getReflection($class, $method)->getAttributes($this->getClassName($name)); |
||
31 | if(count($attributes) === 0) { |
||
32 | return null; |
||
33 | } |
||
34 | return $attributes[0]->getArguments()[0] ?? null; |
||
35 | } |
||
36 | |||
37 | private function isAvailable(): bool { |
||
39 | } |
||
40 | |||
41 | private function getClassName(string $baseName): string { |
||
42 | return "MyTester\\Annotations\Attributes\\" . Strings::firstUpper($baseName); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string|object $class |
||
47 | * @return ReflectionClass|ReflectionMethod |
||
48 | * @throws ReflectionException |
||
49 | */ |
||
50 | private function getReflection($class, string $method = null): Reflector { |
||
57 | } |
||
58 | } |
||
59 | ?> |