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   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C handle() 0 25 8
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