Completed
Pull Request — 2.x (#29)
by Akihito
01:35
created

ErrorPagerRenderer::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
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
    public function __construct(\Twig_Environment $twig, string $errorPage)
26
    {
27
        $this->twig = $twig;
28
        $this->errorPage = $errorPage;
29
    }
30
31
    /**
32
     * @throws \Twig_Error_Loader
33
     * @throws \Twig_Error_Runtime
34
     * @throws \Twig_Error_Syntax
35
     *
36
     * @return string
37
     */
38
    public function render(ResourceObject $ro)
39
    {
40
        $ro->view = $this->twig->render($this->errorPage, $ro->body);
41
42
        return $ro->view;
43
    }
44
}
45