| 1 | <?php |
||
| 13 | abstract class BaseMatcher implements Matcher |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var int Start matching from |
||
| 17 | */ |
||
| 18 | private $startPos; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var int Length to match |
||
| 22 | */ |
||
| 23 | private $length; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Set match area |
||
| 27 | * |
||
| 28 | * Note that to make matcher definitions and the technical specifications of |
||
| 29 | * autoirot appear as similar as possible the first character of a line is |
||
| 30 | * regarded as being in position one (1). |
||
| 31 | */ |
||
| 32 | 8 | public function __construct(int $startPos, int $length) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Get a description of the expected content |
||
| 40 | */ |
||
| 41 | abstract protected function getDescription(): string; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Check if string is valid according to matching rules |
||
| 45 | */ |
||
| 46 | abstract protected function isMatch(string $str): bool; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Match line and grab substring on success |
||
| 50 | * |
||
| 51 | * @throws InvalidContentException if line does not match |
||
| 52 | */ |
||
| 53 | 8 | public function match(Line $line): string |
|
| 70 | } |
||
| 71 |