Completed
Push — master ( bdabef...6d4bc5 )
by Derek Stephen
07:41
created

Client::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 2
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace OAuth;
4
5
use League\OAuth2\Server\Entities\ClientEntityInterface;
6
7
/**
8
 * @Entity(repositoryClass="OAuth\Repository\ClientRepository")
9
 * @Table(name="Client")
10
 */
11
class Client implements ClientEntityInterface
12
{
13
14
    /**
15
     * @var string
16
     * @Column(type="string", length=40)
17
     */
18
    protected $name;
19
20
    /**
21
     * @var string|string[]
22
     * @Column(type="string", length=255)
23
     */
24
    protected $redirectUri;
25
26
    /**
27
     * @var string
28
     * @Id
29
     * @Column(type="string", length=40)
30
     */
31
    protected $identifier;
32
33
    /**
34
     * @return string
35
     */
36 1
    public function getIdentifier()
37
    {
38 1
        return $this->identifier;
39
    }
40
41
    /**
42
     * @param string $identifier
43
     */
44 1
    public function setIdentifier($identifier)
45
    {
46 1
        $this->identifier = $identifier;
47 1
    }
48
49
    /**
50
     * Get the client's name.
51
     *
52
     * @return string
53
     */
54 3
    public function getName()
55
    {
56 3
        return $this->name;
57
    }
58
59
    /**
60
     * Returns the registered redirect URI (as a string).
61
     *
62
     * Alternatively return an indexed array of redirect URIs.
63
     *
64
     * @return string|string[]
65
     */
66 1
    public function getRedirectUri()
67
    {
68 1
        return $this->redirectUri;
69
    }
70
71
    /**
72
     * @param string $name
73
     * @return Client
74
     */
75 3
    public function setName(string $name): Client
76
    {
77 3
        $this->name = $name;
78 3
        return $this;
79
    }
80
81
    /**
82
     * @param string|\string[] $redirectUri
83
     * @return Client
84
     */
85 1
    public function setRedirectUri($redirectUri)
86
    {
87 1
        $this->redirectUri = $redirectUri;
0 ignored issues
show
Documentation Bug introduced by
It seems like $redirectUri can also be of type array<integer,object<string>>. However, the property $redirectUri is declared as type string|array<integer,string>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
88 1
        return $this;
89
    }
90
}