| Total Complexity | 3 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Tarsana\Command\Template\Twig; |
||
| 10 | class TwigLoader implements TemplateLoaderInterface { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Twig Environment. |
||
| 14 | * |
||
| 15 | * @var \Twig_Environment |
||
| 16 | */ |
||
| 17 | protected $env; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Initialize the loader. |
||
| 21 | * |
||
| 22 | * @param string $templatesPath |
||
| 23 | * @param string $cachePath |
||
| 24 | * @return self |
||
| 25 | */ |
||
| 26 | public function init(string $templatesPath, string $cachePath = null) : TemplateLoaderInterface |
||
| 27 | { |
||
| 28 | $loader = new \Twig_Loader_Filesystem($templatesPath); |
||
|
|
|||
| 29 | if (null !== $cachePath) { |
||
| 30 | $this->env = new \Twig_Environment($loader, [ |
||
| 31 | 'cache' => $cachePath, |
||
| 32 | ]); |
||
| 33 | } else { |
||
| 34 | $this->env = new \Twig_Environment($loader); |
||
| 35 | } |
||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Loads a template. |
||
| 41 | * |
||
| 42 | * @param string $name |
||
| 43 | * @return Tarsana\Command\Template\Twig\TwigTemplate |
||
| 44 | */ |
||
| 45 | public function load(string $name) : TemplateInterface |
||
| 48 | } |
||
| 49 | |||
| 51 |