Total Complexity | 5 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 18.18% |
Changes | 0 |
1 | <?php |
||
17 | trait TokenTrait |
||
18 | { |
||
19 | /** |
||
20 | * Returns the JWT token object. |
||
21 | * |
||
22 | * @param string $token |
||
23 | * |
||
24 | * @return Token |
||
25 | */ |
||
26 | 65 | protected function getToken(string $token): Token |
|
27 | { |
||
28 | 65 | return (new Parser())->parse($token); |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * Returns the default audience for the tokens. |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | protected function getTokenAudience(): string |
||
37 | { |
||
38 | /** @var string $audience */ |
||
39 | $audience = envValue('TOKEN_AUDIENCE', ''); |
||
40 | |||
41 | return $audience; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Returns the time the token is issued at. |
||
46 | * |
||
47 | * @return int |
||
48 | */ |
||
49 | protected function getTokenTimeIssuedAt(): int |
||
50 | { |
||
51 | return time(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Returns the time drift i.e. token will be valid not before. |
||
56 | * |
||
57 | * @return int |
||
58 | */ |
||
59 | protected function getTokenTimeNotBefore(): int |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Returns the expiry time for the token. |
||
66 | * |
||
67 | * @return int |
||
68 | */ |
||
69 | protected function getTokenTimeExpiration(): int |
||
72 | } |
||
73 | } |
||
74 |