Completed
Push — master ( ba7b2b...21cd4a )
by Woody
04:45
created

PlatesFormatter::template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Equip\Formatter;
4
5
use Equip\Adr\PayloadInterface;
6
use Equip\Formatter\HtmlFormatter;
7
use League\Plates\Engine;
8
9
class PlatesFormatter extends HtmlFormatter
10
{
11
    /**
12
     * @var Engine
13
     */
14
    private $engine;
15
16
    /**
17
     * @param Engine $engine
18
     */
19 3
    public function __construct(Engine $engine)
20
    {
21 3
        $this->engine = $engine;
22 3
    }
23
24
    /**
25
     * @inheritDoc
26
     */
27 1
    public function body(PayloadInterface $payload)
28
    {
29 1
        return $this->render($payload);
30
    }
31
32
    /**
33
     * @param PayloadInterface $payload
34
     *
35
     * @return string
36
     */
37 1
    private function render(PayloadInterface $payload)
38
    {
39 1
        $template = $payload->getSetting('template');
40 1
        $output = $payload->getOutput();
41
42 1
        return $this->engine->render($template, $output);
43
    }
44
}
45