Passed
Push — develop ( dfa246...179c36 )
by Francisco
02:27
created

AuthorizeStudent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 19
loc 19
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 7 7 3

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\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Auth\Access\AuthorizationException;
7
8 View Code Duplication
class AuthorizeStudent
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     * @param \Closure                 $next
15
     *
16
     * @throws \Illuminate\Auth\Access\AuthorizationException
17
     *
18
     * @return mixed
19
     */
20
    public function handle($request, Closure $next)
21
    {
22
        if (! auth()->check() || ! auth()->user()->isStudent()) {
23
            throw new AuthorizationException('Unauthorized.');
24
        }
25
26
        return $next($request);
27
    }
28
}
29