| Total Complexity | 6 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 14 | abstract class AbstractBuilder implements BuilderInterface |
||
| 15 | { |
||
| 16 | use InflectorTrait; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var array<array|string> |
||
| 20 | */ |
||
| 21 | private $data; |
||
| 22 | |||
| 23 | 69 | /** |
|
| 24 | * @param array<array|string> $data |
||
| 25 | 69 | */ |
|
| 26 | 23 | public function __construct(array $data) |
|
| 27 | { |
||
| 28 | if (!empty($data['action']) && \is_string($data['action'])) { |
||
| 29 | 69 | $data['action_name'] = $this->getPascalCase($data['action']); |
|
| 30 | 69 | } |
|
| 31 | 69 | ||
| 32 | $this->data = $data; |
||
| 33 | 69 | } |
|
| 34 | |||
| 35 | 69 | public function __toString() |
|
| 36 | { |
||
| 37 | return $this->build(); |
||
| 38 | 69 | } |
|
| 39 | |||
| 40 | 69 | public function build(): string |
|
| 41 | 69 | { |
|
| 42 | $loader = new \Twig\Loader\FilesystemLoader($this->getPathTemplate()); |
||
| 43 | 69 | $twig = new \Twig\Environment($loader); |
|
| 44 | |||
| 45 | return $twig->render($this->getFileTemplate(), $this->data); |
||
| 46 | 4 | } |
|
| 47 | |||
| 48 | 4 | protected function getPathTemplate(): string |
|
| 51 | 64 | } |
|
| 52 | |||
| 53 | 64 | abstract protected function getFileTemplate(): string; |
|
| 54 | } |
||
| 55 |