| Total Complexity | 6 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class Blacklist |
||
| 14 | { |
||
| 15 | private $app; |
||
| 16 | |||
| 17 | private $store; |
||
| 18 | |||
| 19 | protected $cacheName = 'blacklist'; |
||
| 20 | |||
| 21 | public function __construct(App $app) |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * 获取 缓存驱动. |
||
| 30 | * |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function getStore() |
||
| 34 | { |
||
| 35 | return $this->app->cache; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * 加入黑名单. |
||
| 40 | * |
||
| 41 | * @param Token $token |
||
| 42 | * |
||
| 43 | * @return void |
||
| 44 | */ |
||
| 45 | public function add(Token $token) |
||
| 46 | { |
||
| 47 | if (false === $this->has($token)) { |
||
| 48 | $claims = $token->getClaims(); |
||
| 49 | $exp = $claims['exp']->getValue() - time(); |
||
| 50 | $this->store->push($this->cacheName, (string) $token, $exp); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * 是否存在黑名单. |
||
| 56 | * |
||
| 57 | * @param Token $token |
||
| 58 | * |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | public function has(Token $token): Bool |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * 获取所有黑名单. |
||
| 70 | * |
||
| 71 | * @return array |
||
| 72 | */ |
||
| 73 | public function getAll(): Array |
||
| 76 | } |
||
| 77 | } |
||
| 78 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.