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

Authenticate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 8 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