Completed
Push — master ( 003b5e...76542b )
by Woody
38:06 queued 22:13
created

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