Completed
Push — master ( 7eb1a4...254269 )
by LEUNG
03:41
created

Manager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 31
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 2 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
use xiaodi\JWTAuth\Blacklist;
9
10
class Manager
11
{
12
    private $blacklist;
13
14
    public function __construct(Blacklist $blacklist)
15
    {
16
        $this->blacklist = $blacklist;
17
    }
18
19
    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

19
    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...
20
    {
21
    }
22
23
    public function logout(Token $token)
24
    {
25
        $this->blacklist->add($token);
26
    }
27
28
    public function refresh(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

28
    public function refresh(/** @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...
29
    {
30
    }
31
32
    /**
33
     * Undocumented function
34
     *
35
     * @param Token $token
36
     * @return boolean
37
     */
38
    public function hasBlacklist(Token $token)
39
    {
40
        return $this->blacklist->add($token);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->blacklist->add($token) returns the type void which is incompatible with the documented return type boolean.
Loading history...
Bug introduced by
Are you sure the usage of $this->blacklist->add($token) targeting xiaodi\JWTAuth\Blacklist::add() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
41
    }
42
}
43