Completed
Push — master ( be87cd...ee1dde )
by Derek Stephen
01:35
created

NotAllowedDecorator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 19
loc 19
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Bone\Router\Decorator;
4
5
use Bone\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 Laminas\Diactoros\Response\HtmlResponse;
11
12 View Code Duplication
class NotAllowedDecorator extends ExceptionDecorator
0 ignored issues
show
Duplication introduced by
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...
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
Unused Code introduced by
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
}