Completed
Push — master ( 7772bc...b7c027 )
by Derek Stephen
01:36
created

src/Mvc/Router/Decorator/NotFoundDecorator.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Bone\Mvc\Router\Decorator;
4
5
use Bone\Mvc\View\ViewEngine;
6
use Bone\Traits\HasLayoutTrait;
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\MiddlewareInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
use Zend\Diactoros\Response;
12
use Zend\Diactoros\Stream;
13
14 View Code Duplication
class NotFoundDecorator extends ExceptionDecorator implements MiddlewareInterface
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @param ServerRequestInterface $request
18
     * @param RequestHandlerInterface $handler
19
     * @return ResponseInterface
20
     */
21
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
22
    {
23
        $body = $this->viewEngine->render('error/not-found');
24
        $body = $this->viewEngine->render($this->getLayout(), [
25
            'content' => $body,
26
        ]);
27
28
        return $this->getResponseWithBodyAndStatus(new Response\HtmlResponse(''), $body, 404);
29
    }
30
}