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

ErrorPagerRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

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
     * @return string
33
     * @throws \Twig_Error_Loader
34
     * @throws \Twig_Error_Runtime
35
     * @throws \Twig_Error_Syntax
36
     */
37
    public function render(ResourceObject $ro)
38
    {
39
        $ro->view = $this->twig->render($this->errorPage, $ro->body);
40
41
        return $ro->view;
42
    }
43
}
44