| 1 | <?php |
||
| 13 | class RecordReader |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var Matcher\Matcher |
||
| 17 | */ |
||
| 18 | private $matchers = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var callable Record builder |
||
| 22 | */ |
||
| 23 | private $builder; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Inject matchers and builder |
||
| 27 | * |
||
| 28 | * The builder should take an array of values captured by registered |
||
| 29 | * matchers and return a Record object. |
||
| 30 | */ |
||
| 31 | 1 | public function __construct(array $matchers, callable $builder) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Create Record from matched $line content |
||
| 41 | */ |
||
| 42 | 1 | public function readRecord(Line $line): Record |
|
| 52 | |||
| 53 | /** |
||
| 54 | * Add content matcher |
||
| 55 | */ |
||
| 56 | 1 | protected function addMatcher(string $key, Matcher\Matcher $matcher) |
|
| 60 | |||
| 61 | /** |
||
| 62 | * Set record builder |
||
| 63 | */ |
||
| 64 | 1 | protected function setBuilder(callable $builder) |
|
| 68 | } |
||
| 69 |