GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Authenticate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 17.5 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 7
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 7 12 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 Pterodactyl\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Contracts\Auth\Guard;
7
8
class Authenticate
9
{
10
    /**
11
     * The Guard implementation.
12
     *
13
     * @var \Illuminate\Contracts\Auth\Guard
14
     */
15
    protected $auth;
16
17
    /**
18
     * Create a new filter instance.
19
     *
20
     * @param  \Illuminate\Contracts\Auth\Guard  $auth
21
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
22
     */
23
    public function __construct(Guard $auth)
24
    {
25
        $this->auth = $auth;
26
    }
27
28
    /**
29
     * Handle an incoming request.
30
     *
31
     * @param  \Illuminate\Http\Request  $request
32
     * @param  \Closure                  $next
33
     * @return mixed
34
     */
35
    public function handle($request, Closure $next)
36
    {
37 View Code Duplication
        if ($this->auth->guest()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
38
            if ($request->ajax()) {
39
                return response('Unauthorized.', 401);
40
            } else {
41
                return redirect()->guest('auth/login');
42
            }
43
        }
44
45
        return $next($request);
46
    }
47
}
48