Auth::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace HnrAzevedo\Router\Example\Middleware;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Server\RequestHandlerInterface;
8
9
/** 
10
  * @property string $error
11
  */ 
12
class Auth extends Middleware{
13
14
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
15
    {
16
        if(!array_key_exists('user',$_SESSION)){
17
            $this->error = 'The user must be logged in to the system';
18
        }
19
20
        return $handler->handle($request);
21
    }
22
23
}