Completed
Pull Request — master (#333)
by Elan
01:46
created

RenderMiddleware::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
namespace XHGui\Middleware;
4
5
use Psr\Http\Message\RequestInterface as Request;
6
use Psr\Http\Message\ResponseInterface as Response;
7
use Slim\App;
8
9
class RenderMiddleware
10
{
11
    /** @var App */
12
    private $app;
13
14
    public function __construct(App $app)
15
    {
16
        $this->app = $app;
17
    }
18
19
    public function __invoke(Request $req, Response $res, callable $next)
20
    {
21
        $app = $this->app;
22
23
        // Run the controller action/route function
24
        $next();
25
26
        // Render the template.
27
        if (isset($app->controller)) {
28
            $app->controller->render();
0 ignored issues
show
Bug introduced by
The property controller does not seem to exist in Slim\App.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
29
        }
30
    }
31
}
32