AuthMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 1
dl 13
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 10 10 2

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 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