Total Complexity | 9 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | abstract class Match |
||
19 | { |
||
20 | |||
21 | private $length; |
||
22 | |||
23 | /** |
||
24 | * @param string $name |
||
25 | * @return mixed |
||
26 | * @throws \Exception |
||
27 | */ |
||
28 | public function __get($name) |
||
29 | { |
||
30 | switch ($name) { |
||
31 | case 'length': |
||
32 | return $this->length; |
||
33 | case 'results': |
||
34 | return []; |
||
35 | case 'result': |
||
36 | return null; |
||
37 | case 'token': |
||
38 | return null; |
||
39 | } |
||
40 | |||
41 | throw new \InvalidArgumentException("Property name `{$name}` not recognized"); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Create a new match |
||
46 | * |
||
47 | * @param int $length |
||
48 | */ |
||
49 | public function __construct(int $length = 0) |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Resolve any match stuff (should only ever be called from AbstractParser! |
||
56 | * Not for human consumption |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function resolve() |
||
61 | { |
||
62 | return $this; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Return the result for the name specified or the default value if not set. |
||
67 | * |
||
68 | * @param string|null $name |
||
69 | * @param mixed $default |
||
70 | * @return mixed |
||
71 | */ |
||
72 | public function getResult($name = null, $default = null) |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Return whether there is a result for the name specified. |
||
79 | * |
||
80 | * @param string|null $name |
||
81 | * @return boolean |
||
82 | */ |
||
83 | public function hasResult($name = null) |
||
86 | } |
||
87 | |||
88 | } |
||
89 |