SetterLanguage::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2.2559
1
<?php
2
3
namespace Distilleries\Expendable\Http\Middleware;
4
5
use Closure;
6
7
class SetterLanguage
8
{
9
  
10
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param \Illuminate\Http\Request $request
15
     * @param \Closure $next
16
     * @return mixed
17
     */
18 116
    public function handle($request, Closure $next)
19
    {
20
21 116
        if ($request->session()->has('language')) {
22
            $local = $request->session()->get('language', config('app.locale'));
23
            app()->setLocale($local);
0 ignored issues
show
introduced by
The method setLocale() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            app()->/** @scrutinizer ignore-call */ setLocale($local);
Loading history...
24
        }
25
26 116
        return $next($request);
27
    }
28
}