Completed
Branch develop (82845d)
by Mohamed
03:11
created

Locale::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Http\Middleware;
13
14
use Closure;
15
use Illuminate\Contracts\Auth\Guard;
16
use Illuminate\Http\Request;
17
18
/**
19
 * Locale is a Middleware class to set the locale for the current logged in user.
20
 *
21
 * @author Mohamed Alsharaf <[email protected]>
22
 */
23
class Locale extends MiddlewareAbstract
24
{
25
    /**
26
     * Handle an incoming request.
27
     *
28
     * @param Request  $request
29
     * @param \Closure $next
30
     *
31
     * @return mixed
32
     */
33
    public function handle(Request $request, Closure $next)
34
    {
35
        if (!$this->auth->guest()) {
36
            app()->setLocale($this->getLoggedUser()->language);
37 63
        }
38
39 63
        return $next($request);
40 63
    }
41
}
42