AuthMiddleware::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 3
1
<?php
2
3
namespace App\Middleware;
4
5 View Code Duplication
class AuthMiddleware extends Middleware
6
{
7
    public function __invoke($request, $response, $next)
8
    {
9
        if (!$this->container->auth->check()) {
10
            $this->container->flash->addMessage('danger', 'Zaloguj się aby dostać się do tej podstrony');
11
            return $response->withRedirect($this->container->router->pathFor('auth.signin'));
12
        }
13
        
14
        $response = $next($request, $response);
15
        return $response;
16
    }
17
}
18