| Total Complexity | 2 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | class MethodAnnotationReader { |
||
| 20 | private $annotations; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param object|string $object an object or classname |
||
| 24 | * @param string $method the method which we want to inspect for annotations |
||
| 25 | */ |
||
| 26 | public function __construct($object, $method) { |
||
| 27 | $this->annotations = []; |
||
| 28 | |||
| 29 | $reflection = new \ReflectionMethod($object, $method); |
||
| 30 | $docs = $reflection->getDocComment(); |
||
| 31 | |||
| 32 | // extract everything prefixed by @ and first letter uppercase |
||
| 33 | \preg_match_all('/@([A-Z]\w+)/', $docs, $matches); |
||
| 34 | $this->annotations = $matches[1]; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Check if a method contains an annotation |
||
| 39 | * @param string $name the name of the annotation |
||
| 40 | * @return bool true if the annotation is found |
||
| 41 | */ |
||
| 42 | public function hasAnnotation($name) { |
||
| 44 | } |
||
| 45 | } |
||
| 46 |