Completed
Pull Request — 2.x (#29)
by Akihito
02:51
created

ErrorPagerRenderer::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file is part of the Madapaja.TwigModule package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace Madapaja\TwigModule;
8
9
use BEAR\Resource\RenderInterface;
10
use BEAR\Resource\ResourceObject;
11
use Madapaja\TwigModule\Annotation\TwigErrorPath;
12
13
class ErrorPagerRenderer implements RenderInterface
14
{
15
    /**
16
     * @var \Twig_Environment
17
     */
18
    private $twig;
19
20
    private $errorPage;
21
22
    /**
23
     * @TwigErrorPath("errorPage")
24
     */
25 2
    public function __construct(\Twig_Environment $twig, string $errorPage)
26
    {
27 2
        $this->twig = $twig;
28 2
        $this->errorPage = $errorPage;
29 2
    }
30
31
    /**
32
     * @throws \Twig_Error_Loader
33
     * @throws \Twig_Error_Runtime
34
     * @throws \Twig_Error_Syntax
35
     *
36
     * @return string
37
     */
38 1
    public function render(ResourceObject $ro)
39
    {
40 1
        $ro->view = $this->twig->render($this->errorPage, $ro->body);
41
42 1
        return $ro->view;
43
    }
44
}
45