Completed
Push — master ( 56dc59...f8231d )
by Derek Stephen
01:51
created

Client::setSecret()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
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
     * @var string
15
     * @Column(type="string", length=40)
16
     */
17
    private $name;
18
19
    /**
20
     * @var string|string[]
21
     * @Column(type="string", length=255)
22
     */
23
    private $redirectUri;
24
25
    /**
26
     * @var string
27
     * @Id
28
     * @Column(type="string", length=40)
29
     */
30
    private $identifier;
31
32
    /**
33
     * @var string
34
     * @Column(type="string", length=40, nullable=true)
35
     */
36
    private $secret;
37
38
    /**
39
     * @var bool $confidential
40
     */
41
    private $confidential;
42
43
    /**
44
     * @var User $user*
45
     * @ManyToOne(targetEntity="OAuth\User")
46
     * @JoinColumn(name="user", referencedColumnName="id")
47
     */
48
    private $user;
49
50
    /**
51
     * @return string
52
     */
53 1
    public function getIdentifier()
54
    {
55 1
        return $this->identifier;
56
    }
57
58
    /**
59
     * @param string $identifier
60
     */
61 1
    public function setIdentifier($identifier)
62
    {
63 1
        $this->identifier = $identifier;
64 1
    }
65
66
    /**
67
     * Get the client's name.
68
     *
69
     * @return string
70
     */
71 3
    public function getName()
72
    {
73 3
        return $this->name;
74
    }
75
76
    /**
77
     * Returns the registered redirect URI (as a string).
78
     *
79
     * Alternatively return an indexed array of redirect URIs.
80
     *
81
     * @return string|string[]
82
     */
83 1
    public function getRedirectUri()
84
    {
85 1
        return $this->redirectUri;
86
    }
87
88
    /**
89
     * @param string $name
90
     * @return Client
91
     */
92 3
    public function setName($name)
93
    {
94 3
        $this->name = $name;
95 3
        return $this;
96
    }
97
98
    /**
99
     * @param string|\string[] $redirectUri
100
     * @return Client
101
     */
102 1
    public function setRedirectUri($redirectUri)
103
    {
104 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...
105 1
        return $this;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getSecret(): string
112
    {
113
        return $this->secret;
114
    }
115
116
    /**
117
     * @param string $secret
118
     * @return Client
119
     */
120
    public function setSecret(string $secret): Client
121
    {
122
        $this->secret = $secret;
123
        return $this;
124
    }
125
126
    /**
127
     * @return bool
128
     */
129
    public function isConfidential(): bool
130
    {
131
        return $this->confidential;
132
    }
133
134
    /**
135
     * @param bool $confidential
136
     * @return Client
137
     */
138
    public function setConfidential(bool $confidential): Client
139
    {
140
        $this->confidential = $confidential;
141
        return $this;
142
    }
143
144
    /**
145
     * @return User
146
     */
147
    public function getUser(): User
148
    {
149
        return $this->user;
150
    }
151
152
    /**
153
     * @param User $user
154
     * @return Client
155
     */
156
    public function setUser(User $user): Client
157
    {
158
        $this->user = $user;
159
        return $this;
160
    }
161
}