Auth   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 2
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
}