Completed
Push — master ( ee9d02...8bba70 )
by Alex
04:07
created

TwigFormatter::__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 AlexMasterov\EquipTwig;
4
5
use Equip\Formatter\HtmlFormatter;
6
use Twig_Environment;
7
8
final class TwigFormatter extends HtmlFormatter
9
{
10
    /**
11
     * @var Twig_Environment
12
     */
13
    private $environment;
14
15
    /**
16
     * @var string
17
     */
18
    private $template;
19
20
    /**
21
     * @param Twig_Environment $environment
22
     */
23 3
    public function __construct(Twig_Environment $environment)
24
    {
25 3
        $this->environment = $environment;
26 3
    }
27
28
    /**
29
     * Get a copy that uses a different template.
30
     *
31
     * @param string $template
32
     *
33
     * @return static
34
     */
35 1
    public function withTemplate($template)
36
    {
37 1
        $copy = clone $this;
38 1
        $copy->template = $template;
39
40 1
        return $copy;
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46 1
    public function format($content)
47
    {
48 1
        return $this->environment->render($this->template, $content);
49
    }
50
}
51