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.
Completed
Push — master ( 5a4e01...d07e87 )
by Marc
8s
created

LocaleSessionRedirect::handle()   C

Complexity

Conditions 8
Paths 4

Size

Total Lines 25
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 5.3846
cc 8
eloc 13
nc 4
nop 2
1
<?php
2
3
namespace Mcamara\LaravelLocalization\Middleware;
4
5
use Closure;
6
use Illuminate\Http\RedirectResponse;
7
8
class LocaleSessionRedirect extends LaravelLocalizationMiddlewareBase
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     * @param \Closure                 $next
15
     *
16
     * @return mixed
17
     */
18
    public function handle($request, Closure $next)
19
    {
20
        // If the URL of the request is in exceptions.
21
        if ($this->shouldIgnore($request)) {
22
            return $next($request);
23
        }
24
25
        $params = explode('/', $request->path());
26
        $locale = session('locale', false);
27
28
        if (count($params) > 0 && app('laravellocalization')->checkLocaleInSupportedLocales($params[0])) {
29
            session(['locale' => $params[0]]);
30
31
            return $next($request);
32
        }
33
34
        if ($locale && app('laravellocalization')->checkLocaleInSupportedLocales($locale) && !(app('laravellocalization')->getDefaultLocale() === $locale && app('laravellocalization')->hideDefaultLocaleInURL())) {
35
            app('session')->reflash();
36
            $redirection = app('laravellocalization')->getLocalizedURL($locale);
37
38
            return new RedirectResponse($redirection, 302, ['Vary' => 'Accept-Language']);
39
        }
40
41
        return $next($request);
42
    }
43
}
44