Passed
Push — master ( a02115...b30a41 )
by Henri
01:21
created

Auth2::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Example\Middleware;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Server\RequestHandlerInterface;
8
9
class Auth2 extends Middleware{
10
11
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
12
    {
13
        if(!isset($this->error)){
0 ignored issues
show
Bug Best Practice introduced by
The property error does not exist on Example\Middleware\Auth2. Since you implemented __get, consider adding a @property annotation.
Loading history...
14
            var_dump($this->error);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($this->error) looks like debug code. Are you sure you do not want to remove it?
Loading history...
15
            die();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Psr\Http\Message\ResponseInterface. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
16
        }
17
18
        return parent::process($request, $handler);
19
    }
20
21
}