| Total Complexity | 4 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 16.66% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class TwigAdapter |
||
| 15 | { |
||
| 16 | protected Environment $twig; |
||
| 17 | |||
| 18 | public function __construct() |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Renders given template |
||
| 25 | * |
||
| 26 | * @param string $template |
||
| 27 | * @param mixed[] $parameters |
||
| 28 | * @return string |
||
| 29 | */ |
||
| 30 | 1 | public function render(string $template, array $parameters): string |
|
| 31 | { |
||
| 32 | 1 | return $this->twig->render($template, $parameters); |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Setups Twig template engine |
||
| 37 | */ |
||
| 38 | protected function setup(): void |
||
| 39 | { |
||
| 40 | $this->twig = new Environment( |
||
| 41 | new FilesystemLoader($this->getGorynychTemplatesPath()), |
||
| 42 | [ |
||
| 43 | 'cache' => dirname(__DIR__, 2) . '/var/twig', |
||
| 44 | ] |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Returns path to Gorynych templates |
||
| 50 | * This path must be included in setup process, if you want to take advantage of ApiGenerator |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | final protected function getGorynychTemplatesPath(): string |
||
| 57 | } |
||
| 58 | } |
||
| 59 |