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