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

src/Mvc/Router/Decorator/NotAllowedDecorator.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 Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\MiddlewareInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
use Zend\Diactoros\Response\HtmlResponse;
11
12 View Code Duplication
class NotAllowedDecorator extends ExceptionDecorator
13
{
14
    /**
15
     * @param ServerRequestInterface $request
16
     * @param RequestHandlerInterface $handler
17
     * @return ResponseInterface
18
     */
19
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
20
    {
21
        $body = $this->viewEngine->render('error/not-allowed');
22
        $body = $this->viewEngine->render($this->getLayout(), [
23
            'content' => $body,
24
        ]);
25
26
        return $this->getResponseWithBodyAndStatus(new HtmlResponse(''), $body, 405);
27
28
        return parent::process($request, $handler);
0 ignored issues
show
return parent::process($request, $handler); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
29
    }
30
}