Completed
Push — develop ( 157e47...580015 )
by Abdelrahman
02:00
created

AuthenticateWithBasicAuth::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Http\Middleware;
6
7
use Closure;
8
use Illuminate\Contracts\Auth\Factory as AuthFactory;
9
10
class AuthenticateWithBasicAuth
11
{
12
    /**
13
     * The guard factory instance.
14
     *
15
     * @var \Illuminate\Contracts\Auth\Factory
16
     */
17
    protected $auth;
18
19
    /**
20
     * Create a new middleware instance.
21
     *
22
     * @param  \Illuminate\Contracts\Auth\Factory $auth
23
     *
24
     * @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...
25
     */
26
    public function __construct(AuthFactory $auth)
27
    {
28
        $this->auth = $auth;
29
    }
30
31
    /**
32
     * Handle an incoming request.
33
     *
34
     * @param  \Illuminate\Http\Request $request
35
     * @param  \Closure                 $next
36
     * @param  string|null              $guard
37
     * @param  string|null              $field
38
     *
39
     * @return mixed
40
     */
41
    public function handle($request, Closure $next, $guard = null, $field = null)
42
    {
43
        return $this->auth->guard($guard)->basic($field) ?: $next($request);
44
    }
45
}
46