UserMiddleware   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\AuthMiddleware;
4
5
use App\Middleware\Middleware;
6
7 View Code Duplication
class UserMiddleware extends Middleware
8
{
9
    public function __invoke($request, $response, $next)
10
    {
11
        if (!$this->container->auth->check()) {
12
            $this->container->flash->addMessage('danger', 'Zaloguj się aby dostać się do tej podstrony');
13
            return $response->withRedirect($this->container->router->pathFor('auth.signin'));
14
        }
15
        
16
        $response = $next($request, $response);
17
        return $response;
18
    }
19
}
20