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

ErrorPagerRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 32
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

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