Completed
Push — master ( dbc3bd...6bde35 )
by Mahmoud
03:28
created

Authenticate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace App\Containers\WebAuthentication\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 Authenticate
12
 *
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class Authenticate
16
{
17
    /**
18
     * The Guard implementation.
19
     *
20
     * @var Guard
21
     */
22
    protected $auth;
23
24
    /**
25
     * @var  \App\Port\Butler\Portals\PortButler
26
     */
27
    private $portButler;
28
29
    /**
30
     * Create a new middleware instance.
31
     *
32
     * @param  Guard  $auth
33
     * @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...
34
     */
35
    public function __construct(Guard $auth, PortButler $portButler)
36
    {
37
        $this->auth = $auth;
38
        $this->portButler = $portButler;
39
    }
40
41
    /**
42
     * Handle an incoming request.
43
     *
44
     * @param  \Illuminate\Http\Request  $request
45
     * @param  \Closure  $next
46
     * @return mixed
47
     */
48
    public function handle(Request $request, Closure $next)
49
    {
50
        if ($this->auth->guest()) {
51
            return view($this->portButler->getLoginWebPageName());
52
        }
53
54
        return $next($request);
55
    }
56
}
57