Completed
Push — master ( ef610a...dc0762 )
by Gabor
24:45
created

FakeRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 19 2
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 5.6
6
 *
7
 * @copyright 2012 - 2016 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
namespace WebHemi\Adapter\Renderer;
13
14
use Psr\Http\Message\StreamInterface;
15
16
/**
17
 * Class FakeRenderer.
18
 */
19
class FakeRenderer implements RendererAdapterInterface
20
{
21
    /**
22
     * Renders the template for the output.
23
     *
24
     * @param string $template
25
     * @param array  $parameters
26
     *
27
     * @return StreamInterface
28
     */
29
    public function render($template, $parameters = [])
30
    {
31
        $output = '<h1>Hello world!</h1>';
32
33
        if (isset($parameters['exception'])) {
34
            /** @var \Exception $exp */
35
            $exp = $parameters['exception'];
36
            $output .= '<p>' . $exp->getMessage() . '</p>';
37
            $output .= '<p>' . $exp->getFile() . ' at line ' . $exp->getLine() . '</p>';
38
            $output .= '<pre>' . $exp->getTraceAsString() . '</pre>';
39
        } else {
40
            $output .= $parameters[0];
41
        }
42
43
        $output .= '<p>' . $template . '</p>';
44
45
        // The ugliest shit ever. But that is how they made it... :/
46
        return \GuzzleHttp\Psr7\stream_for($output);
47
    }
48
}
49