Manager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 57
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A refresh() 0 4 1
A hasBlacklist() 0 3 1
A login() 0 2 1
A logout() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace xiaodi\JWTAuth;
6
7
use Lcobucci\JWT\Token;
8
9
class Manager
10
{
11
    private $blacklist;
12
13
    public function __construct(Blacklist $blacklist)
14
    {
15
        $this->blacklist = $blacklist;
16
    }
17
18
    /**
19
     * 处理登录时.
20
     *
21
     * @param Token $token
22
     *
23
     * @return void
24
     */
25
    public function login(Token $token)
0 ignored issues
show
Unused Code introduced by
The parameter $token is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
    public function login(/** @scrutinizer ignore-unused */ Token $token)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        // TODO 但凡获取新token后 都把以前的注销(黑名单)
28
        // $jti = $token->getClaim('jti');
29
    }
30
31
    /**
32
     * 处理登出时.
33
     *
34
     * @param Token $token
35
     *
36
     * @return void
37
     */
38
    public function logout(Token $token)
39
    {
40
        $this->blacklist->add($token);
41
    }
42
43
    /**
44
     * 处理刷新时.
45
     *
46
     * @param Token $token
47
     *
48
     * @return void
49
     */
50
    public function refresh(Token $token)
51
    {
52
        // 注销此Token
53
        $this->logout($token);
54
    }
55
56
    /**
57
     * 是否存在黑名单.
58
     *
59
     * @param Token $token
60
     *
61
     * @return bool
62
     */
63
    public function hasBlacklist(Token $token)
64
    {
65
        return $this->blacklist->has($token);
66
    }
67
}
68