IlluminateAuthAdapter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 5
c 3
b 2
f 0
lcom 1
cbo 0
dl 0
loc 51
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A byCredentials() 0 4 1
A byId() 0 8 2
A user() 0 4 1
1
<?php
2
3
namespace Tymon\JWTAuth\Providers\Auth;
4
5
use Exception;
6
use Illuminate\Auth\AuthManager;
7
8
class IlluminateAuthAdapter implements AuthInterface
9
{
10
    /**
11
     * @var \Illuminate\Auth\AuthManager
12
     */
13
    protected $auth;
14
15
    /**
16
     * @param \Illuminate\Auth\AuthManager  $auth
17
     */
18 12
    public function __construct(AuthManager $auth)
19
    {
20 12
        $this->auth = $auth;
21 12
    }
22
23
    /**
24
     * Check a user's credentials
25
     *
26
     * @param  array  $credentials
27
     * @return bool
28
     */
29 3
    public function byCredentials(array $credentials = [])
30
    {
31 3
        return $this->auth->once($credentials);
32
    }
33
34
    /**
35
     * Authenticate a user via the id
36
     *
37
     * @param  mixed  $id
38
     * @return bool
39
     */
40 6
    public function byId($id)
41
    {
42
        try {
43 6
            return $this->auth->onceUsingId($id);
44 3
        } catch (Exception $e) {
45 3
            return false;
46
        }
47
    }
48
49
    /**
50
     * Get the currently authenticated user
51
     *
52
     * @return mixed
53
     */
54 3
    public function user()
55
    {
56 3
        return $this->auth->user();
57
    }
58
}
59