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 ( 3c14c6...dd6b89 )
by Marc
7s
created

LocaleCookieRedirect::handle()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 13
Ratio 59.09 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 13
loc 22
rs 8.6737
cc 6
eloc 11
nc 3
nop 2
1
<?php namespace Mcamara\LaravelLocalization\Middleware;
2
3
use Illuminate\Http\RedirectResponse;
4
use Closure;
5
6
class LocaleCookieRedirect {
7
8
    /**
9
     * Handle an incoming request.
10
     *
11
     * @param  \Illuminate\Http\Request $request
12
     * @param  \Closure $next
13
     * @return mixed
14
     */
15
    public function handle( $request, Closure $next )
16
    {
17
        $params = explode('/', $request->path());
18
        $locale = $request->cookie('locale', false);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string|array|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
19
20 View Code Duplication
        if ( count($params) > 0 && app('laravellocalization')->checkLocaleInSupportedLocales($params[ 0 ]) )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
        {
22
            cookie('locale', $params[ 0 ]);
23
24
            return $next($request);
25
        }
26
27 View Code Duplication
        if ( $locale && !( app('laravellocalization')->getDefaultLocale() === $locale && app('laravellocalization')->hideDefaultLocaleInURL() ) )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
        {
29
            app('session')->reflash();
30
            $redirection = app('laravellocalization')->getLocalizedURL($locale);
31
32
            return new RedirectResponse($redirection, 302, [ 'Vary' => 'Accept-Language' ]);
33
        }
34
35
        return $next($request);
36
    }
37
}