SetLocale::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CaribouFute\LocaleRoute\Middleware;
4
5
use CaribouFute\LocaleRoute\Session\Locale as SessionLocale;
6
use Closure;
7
8
class SetLocale
9
{
10
    protected $sessionLocale;
11
12
    public function __construct(SessionLocale $sessionLocale)
13
    {
14
        $this->sessionLocale = $sessionLocale;
15
    }
16
17
    /**
18
     * Handle the incoming request.
19
     *
20
     * @param  \Illuminate\Http\Request  $request
21
     * @param  \Closure  $next
22
     * @return mixed
23
     */
24
    public function handle($request, Closure $next)
25
    {
26
        app()->setLocale($this->sessionLocale->get());
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

26
        app()->/** @scrutinizer ignore-call */ setLocale($this->sessionLocale->get());
Loading history...
27
28
        return $next($request);
29
    }
30
}
31