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

TwigFormatter::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 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