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::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 7
Ratio 58.33 %

Importance

Changes 0
Metric Value
dl 7
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 2
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