Completed
Push — master ( ac98e3...f24a74 )
by Alex
21:21 queued 18:09
created

TwigFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A body() 0 4 1
A render() 0 7 1
1
<?php
2
3
namespace Asmaster\EquipTwig;
4
5
use Equip\Adr\PayloadInterface;
6
use Equip\Formatter\HtmlFormatter;
7
use Twig_Environment as TwigEnvironment;
8
9
final class TwigFormatter extends HtmlFormatter
10
{
11
    /**
12
     * @var TwigEnvironment
13
     */
14
    private $environment;
15
16
    /**
17
     * @param TwigEnvironment $environment
18
     */
19 3
    public function __construct(TwigEnvironment $environment)
20
    {
21 3
        $this->environment = $environment;
22 3
    }
23
24
    /**
25
     * @param PayloadInterface $payload
26
     *
27
     * @return string
28
     */
29 1
    public function body(PayloadInterface $payload)
30
    {
31 1
        return $this->render($payload);
32
    }
33
34
    /**
35
     * @param PayloadInterface $payload
36
     *
37
     * @return string
38
     */
39 1
    private function render(PayloadInterface $payload)
40
    {
41 1
        $template = $payload->getSetting('template');
42 1
        $output = $payload->getOutput();
43
44 1
        return $this->environment->render($template, $output);
45
    }
46
}
47