| Total Complexity | 6 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | abstract class Generator |
||
| 23 | { |
||
| 24 | /** @var ProcessorProgressDisplay */ |
||
| 25 | private $display; |
||
| 26 | |||
| 27 | /** @var CodeParser */ |
||
| 28 | private $parser; |
||
| 29 | |||
| 30 | 66 | public function __construct(CodeParser $parser) |
|
| 31 | { |
||
| 32 | 66 | $this->parser = $parser; |
|
| 33 | 66 | } |
|
| 34 | |||
| 35 | 54 | public function attach(ProcessorProgressDisplay $display): void |
|
| 36 | { |
||
| 37 | 54 | $this->display = $display; |
|
| 38 | 54 | } |
|
| 39 | |||
| 40 | /** @throws LogicException */ |
||
| 41 | 60 | protected function display(): ProcessorProgressDisplay |
|
| 42 | { |
||
| 43 | 60 | if (!$this->display) { |
|
| 44 | 12 | throw new LogicException('No display was attached'); |
|
| 45 | } |
||
| 46 | 48 | return $this->display; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @throws \LogicException If the command is missing |
||
| 51 | */ |
||
| 52 | 48 | protected function parseCode(CodeFinder $finder): Structure |
|
| 53 | { |
||
| 54 | 48 | $this->display()->runningParser(); |
|
| 55 | 48 | return $this->parser->parse($finder); |
|
| 56 | } |
||
| 57 | |||
| 58 | 48 | protected function save(Processor $processor, string $content, string $path): void |
|
| 62 | 48 | } |
|
| 63 | } |
||
| 64 |