Completed
Pull Request — 1.x (#19)
by IWASAKI
04:35 queued 02:12
created

OriginalTwigEnvironmentProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Madapaja\TwigModule;
4
5
use Madapaja\TwigModule\Annotation\TwigOptions;
6
use Ray\Di\Di\Inject;
7
use Ray\Di\Di\Named;
8
use Ray\Di\ProviderInterface;
9
use Twig_LoaderInterface;
10
use Twig_Environment;
11
12
class OriginalTwigEnvironmentProvider implements ProviderInterface
13
{
14
    private $loader;
15
    private $options = [];
16
17
    /**
18
     * @Named("twig_loader")
19
     * @param Twig_LoaderInterface $loader
20
     */
21 21
    public function __construct(Twig_LoaderInterface $loader)
22
    {
23 21
        $this->loader = $loader;
24 21
    }
25
26
    /**
27
     * @Inject
28
     * @TwigOptions
29
     * @param array $options
30
     */
31 21
    public function setOptions(array $options = [])
32
    {
33 21
        $this->options = $options;
34 21
    }
35
36
    /**
37
     * @return Twig_Environment
38
     */
39 21
    public function get()
40
    {
41 21
        return new Twig_Environment($this->loader, $this->options);
42
    }
43
}
44