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

PlatesFormatter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 44
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A body() 0 6 1
A template() 0 4 1
A render() 0 4 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