| 1 | <?php |
||
| 12 | abstract class ParserBase |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $config; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var Parser |
||
| 21 | */ |
||
| 22 | protected $parser; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Constructor |
||
| 26 | * |
||
| 27 | * @param Parser $parser |
||
| 28 | * @param array $config |
||
| 29 | */ |
||
| 30 | 3 | final public function __construct(Parser $parser, array $config) |
|
| 31 | { |
||
| 32 | 3 | $this->parser = $parser; |
|
| 33 | 3 | $this->config = $config; |
|
| 34 | |||
| 35 | 3 | $this->setUp(); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Plugin's setup |
||
| 40 | * |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | protected function setUp() |
||
| 44 | { |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $text |
||
| 49 | * @param array $matches If the config array has a "regexp" key, the corresponding matches are |
||
| 50 | * passed as second parameter. Otherwise, an empty array is passed |
||
| 51 | * @return void |
||
| 52 | */ |
||
| 53 | abstract public function parse($text, array $matches); |
||
| 54 | } |