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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 25
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 5
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