Completed
Push — master ( e93f60...2f787f )
by Mahmoud
08:56 queued 02:41
created

JwtAuthAdapter::parseToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Authentication\Adapters;
4
use Tymon\JWTAuth\Facades\JWTFactory;
5
use Tymon\JWTAuth\JWTAuth;
6
7
/**
8
 * Class JWTAuthTask.
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class JwtAuthAdapter
13
{
14
15
    /**
16
     * @var \JWTAuth
17
     */
18
    private $jwtAuth;
19
20
    public function __construct(JWTAuth $jwtAuth)
21
    {
22
        $this->jwtAuth = $jwtAuth;
0 ignored issues
show
Documentation Bug introduced by
It seems like $jwtAuth of type object<Tymon\JWTAuth\JWTAuth> is incompatible with the declared type object<JWTAuth> of property $jwtAuth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
    }
24
25
    /**
26
     * @param $credentials
27
     *
28
     * @return mixed
29
     */
30
    public function attempt($credentials)
31
    {
32
        return $this->jwtAuth->attempt($credentials);
33
    }
34
35
    /**
36
     * @param $token
37
     *
38
     * @return mixed
39
     */
40
    public function toUser($token)
41
    {
42
        return $this->jwtAuth->toUser($token);
43
    }
44
45
    /**
46
     * @return  \Tymon\JWTAuth\JWTAuth
47
     */
48
    public function parseToken()
49
    {
50
        return $this->jwtAuth->parseToken();
51
    }
52
53
    /**
54
     * @param $user
55
     *
56
     * @return mixed
57
     */
58
    public function fromUser($user, array $customClaims = [])
59
    {
60
        return $this->jwtAuth->fromUser($user, $customClaims);
61
    }
62
63
    /**
64
     * @param bool|false $token
65
     *
66
     * @return mixed
67
     */
68
    public function invalidate($token)
69
    {
70
        return $this->jwtAuth->invalidate($token);
71
    }
72
73
    /**
74
     * @return mixed
75
     */
76
    public function getToken()
77
    {
78
        return $this->jwtAuth->getToken();
79
    }
80
81
    /**
82
     * @return  \Tymon\JWTAuth\Payload
83
     */
84
    public function getPayload()
85
    {
86
        return $this->jwtAuth->getPayload();
87
    }
88
89
    /**
90
     * @param $token
91
     *
92
     * @return mixed
93
     */
94
    public function setToken($token)
95
    {
96
        return $this->jwtAuth->setToken($token);
97
    }
98
99
    /**
100
     * @param $token
101
     *
102
     * @return  mixed
103
     */
104
    public function authenticateViaToken($token = null)
105
    {
106
        return $this->jwtAuth->authenticate($token);
107
    }
108
109
    /**
110
     * @param $customClaims
111
     *
112
     * @return  mixed
113
     */
114
    public function makeTokenWithCustomClaims($customClaims)
115
    {
116
        $payload = JWTFactory::make($customClaims);
117
118
        return $this->jwtAuth->encode($payload)->get();
119
    }
120
121
}
122