Completed
Push — master ( da3ad7...57e63a )
by Mahmoud
04:58
created

Authentication::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace App\Containers\Authentication\Middlewares;
4
5
use App\Port\Butler\Portals\PortButler;
6
use Closure;
7
use Illuminate\Contracts\Auth\Guard;
8
use Illuminate\Http\Request;
9
10
/**
11
 * Class WebAuthentication
12
 *
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class WebAuthentication
16
{
17
18
    /**
19
     * The Guard implementation.
20
     *
21
     * @var Guard
22
     */
23
    protected $auth;
24
25
    /**
26
     * @var  \App\Port\Butler\Portals\PortButler
27
     */
28
    private $portButler;
29
30
    /**
31
     * Create a new middleware instance.
32
     *
33
     * @param  Guard $auth
34
     *
35
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
36
     */
37
    public function __construct(Guard $auth, PortButler $portButler)
38
    {
39
        $this->auth = $auth;
40
        $this->portButler = $portButler;
41
    }
42
43
    /**
44
     * Handle an incoming request.
45
     *
46
     * @param  \Illuminate\Http\Request $request
47
     * @param  \Closure                 $next
48
     *
49
     * @return mixed
50
     */
51
    public function handle(Request $request, Closure $next)
52
    {
53
        if ($this->auth->guest()) {
54
            return view($this->portButler->getLoginWebPageName());
55
        }
56
57
        return $next($request);
58
    }
59
}
60