TwigFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 40
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0

3 Methods

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