Completed
Push — develop ( 53b1d2...e700e7 )
by Paul
03:00
created

AbstractPhpRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 4 1
A __construct() 0 3 1
1
<?php
2
3
namespace PhpUnitGen\Renderer;
4
5
use Slim\Views\PhpRenderer;
6
7
/**
8
 * Class AbstractRendererInterface.
9
 *
10
 * @author     Paul Thébaud <[email protected]>.
11
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
12
 * @license    https://opensource.org/licenses/MIT The MIT license.
13
 * @link       https://github.com/paul-thebaud/phpunit-generator
14
 * @since      Class available since Release 2.0.0.
15
 */
16
abstract class AbstractPhpRenderer
17
{
18
    /**
19
     * @var PhpRenderer $renderer The php renderer from slim framework.
20
     */
21
    private $renderer;
22
23
    /**
24
     * AbstractRendererInterface constructor.
25
     *
26
     * @param PhpRenderer $renderer The php renderer.
27
     */
28
    public function __construct(PhpRenderer $renderer)
29
    {
30
        $this->renderer = $renderer;
31
    }
32
33
    /**
34
     * Render a view and merge view data.
35
     *
36
     * @param string $view The view to render.
37
     * @param array  $data The data to add.
38
     *
39
     * @return string The render result.
40
     */
41
    protected function render(string $view, array $data): string
42
    {
43
        $this->renderer->setAttributes(array_merge($this->renderer->getAttributes(), $data));
44
        return $this->renderer->fetch($view);
45
    }
46
}
47