| 1 | <?php |
||
| 10 | class RecordReader |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Mathcer\Matcher |
||
| 14 | */ |
||
| 15 | private $matchers = []; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var callable Record builder |
||
| 19 | */ |
||
| 20 | private $builder; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Inject Record builder |
||
| 24 | * |
||
| 25 | * The builder should take an array of values captured by registered |
||
| 26 | * matchers and return a Record object. |
||
| 27 | */ |
||
| 28 | 1 | public function __construct(callable $builder) |
|
| 32 | |||
| 33 | /** |
||
| 34 | * Capture content matching $matcher |
||
| 35 | */ |
||
| 36 | 1 | public function match(string $key, Matcher\Matcher $matcher): self |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Create Record from matched $line content |
||
| 44 | */ |
||
| 45 | 1 | public function readRecord(Line $line): Record |
|
| 55 | } |
||
| 56 |