Total Complexity | 5 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | |||
12 | namespace Micro\Plugin\Twig\Business\Environment; |
||
13 | |||
14 | use Micro\Plugin\Twig\Business\Loader\LoaderProcessorInterface; |
||
15 | use Micro\Plugin\Twig\TwigPluginConfigurationInterface; |
||
16 | use Twig\Environment; |
||
17 | use Twig\Loader\FilesystemLoader; |
||
18 | use Twig\Loader\LoaderInterface; |
||
19 | |||
20 | readonly class EnvironmentFactory implements EnvironmentFactoryInterface |
||
|
|||
21 | { |
||
22 | 2 | public function __construct( |
|
23 | private TwigPluginConfigurationInterface $pluginConfiguration, |
||
24 | private LoaderProcessorInterface $environmentLoaderProcessor |
||
25 | ) { |
||
26 | 2 | } |
|
27 | |||
28 | 1 | public function create(): Environment |
|
29 | { |
||
30 | 1 | $twig = $this->createEnvironment(); |
|
31 | |||
32 | 1 | $this->environmentLoaderProcessor->load($twig); |
|
33 | |||
34 | 1 | return $twig; |
|
35 | } |
||
36 | |||
37 | 1 | protected function createEnvironment(): Environment |
|
38 | { |
||
39 | 1 | return new Environment( |
|
40 | 1 | $this->createLoader(), |
|
41 | 1 | $this->createEnvironmentConfigurationArray() |
|
42 | 1 | ); |
|
43 | } |
||
44 | |||
45 | 1 | protected function createLoader(): LoaderInterface |
|
46 | { |
||
47 | 1 | return new FilesystemLoader(); |
|
58 |