SetterLanguage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 20
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
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
}