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.

RedirectRequests::handle()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
rs 9.4555
cc 5
nc 4
nop 2
1
<?php
2
3
namespace Neurony\Redirects\Middleware;
4
5
use Closure;
6
7
class RedirectRequests
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param $request
13
     * @param Closure $next
14
     * @return mixed
15
     */
16
    public function handle($request, Closure $next)
17
    {
18
        $redirect = app('redirect.model')->findValidOrNull($request->path());
19
20
        if (! $redirect && $request->getQueryString()) {
21
            $path = $request->path().'?'.$request->getQueryString();
22
            $redirect = app('redirect.model')->findValidOrNull($path);
23
        }
24
25
        if ($redirect && $redirect->exists) {
26
            return redirect($redirect->new_url, $redirect->status);
27
        }
28
29
        return $next($request);
30
    }
31
}
32