| 1 | <?php |
||
| 4 | class ParsedClass extends ParsedObject |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * @var string |
||
| 8 | */ |
||
| 9 | private $namespace; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * A collection of methods belonging |
||
| 13 | * to the parsed class |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | private $methods; |
||
| 18 | |||
| 19 | 34 | public function __construct($doc, $name, $namespace, $methods = array()) |
|
| 20 | { |
||
| 21 | 34 | parent::__construct($doc, $name); |
|
| 22 | 34 | $this->namespace = $namespace; |
|
| 23 | 34 | $this->methods = $methods; |
|
| 24 | 34 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * Return the methods of this parsed class |
||
| 28 | * optionally filtering on annotations present |
||
| 29 | * on a method |
||
| 30 | * |
||
| 31 | * @param array $annotations |
||
| 32 | * @return array |
||
| 33 | */ |
||
| 34 | 24 | public function getMethods($annotations = array()) |
|
| 35 | { |
||
| 36 | $methods = array_filter($this->methods, function ($m) use ($annotations) { |
||
| 37 | 24 | foreach ($annotations as $a => $v) { |
|
| 38 | 3 | foreach (explode(',', $v) as $subValue) { |
|
| 39 | 3 | if ($m->hasAnnotation($a, $subValue)) { |
|
| 40 | 3 | return true; |
|
| 41 | } |
||
| 42 | 3 | } |
|
| 43 | 24 | } |
|
| 44 | 24 | return false; |
|
| 45 | 24 | }); |
|
| 46 | 24 | return $methods ? $methods : $this->methods; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Return the namespace of the parsed class |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | 1 | public function getNamespace() |
|
| 58 | } |
||
| 59 |