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.

MmexEnsureGuid::handle()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 2
nop 2
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use App\Models\User;
6
use App\Services\Mmex\MmexConstants;
7
use Auth;
8
use Closure;
9
10
class MmexEnsureGuid
11
{
12
    /**
13
     * Handle an incoming request.
14
     *
15
     * @param \Illuminate\Http\Request $request
16
     * @param \Closure                 $next
17
     *
18
     * @return mixed
19
     */
20
    public function handle($request, Closure $next)
21
    {
22
        $guid = $request->input('guid');
23
        $user = User::where('mmex_guid', $guid)->first();
24
25
        if ($user && $guid == $user->mmex_guid) {
26
            // login user on api guard (simple alternative login method)
27
            Auth::guard('api')->setUser($user);
28
29
            return $next($request);
30
        }
31
32
        return response(MmexConstants::$wrong_guid)
0 ignored issues
show
Bug introduced by
The method header() does not exist on Symfony\Component\HttpFoundation\Response. Did you maybe mean sendHeaders()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
33
            ->header('Content-Type', 'text/plain; charset=UTF-8');
34
    }
35
}
36