Completed
Push — master ( 67c93c...08a046 )
by Derek Stephen
01:53
created

Client::getScopes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace OAuth;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use League\OAuth2\Server\Entities\ClientEntityInterface;
7
8
/**
9
 * @Entity(repositoryClass="OAuth\Repository\ClientRepository")
10
 * @Table(name="Client",uniqueConstraints={@UniqueConstraint(name="indentifier_idx", columns={"identifier"})})
11
 */
12
class Client implements ClientEntityInterface
13
{
14
15
    /**
16
     * @Id
17
     * @var string
18
     * @Column(type="integer", length=11)
19
     */
20
    private $id;
21
22
    /**
23
     * @var string
24
     * @Column(type="string", length=40)
25
     */
26
    private $name;
27
28
    /**
29
     * @var string|string[]
30
     * @Column(type="string", length=255)
31
     */
32
    private $redirectUri;
33
34
    /**
35
     * @var string
36
     * @Column(type="string", length=40)
37
     */
38
    private $identifier;
39
40
    /**
41
     * @var string
42
     * @Column(type="string", length=40, nullable=true)
43
     */
44
    private $secret;
45
46
    /**
47
     * @var bool $confidential
48
     * @Column(type="boolean")
49
     */
50
    private $confidential;
51
52
    /**
53
     * @var ArrayCollection $scopes
54
     * @ManyToMany(targetEntity="Scope")
55
     * @JoinTable(name="Client_Scope",
56
     *      joinColumns={@JoinColumn(name="client_id", referencedColumnName="id")},
57
     *      inverseJoinColumns={@JoinColumn(name="scope_id", referencedColumnName="identifier")}
58
     *      )
59
     */
60
    private $scopes;
61
62 5
    public function __construct()
63
    {
64 5
        $this->scopes = new ArrayCollection();
65 5
    }
66
67
    /**
68
     * @return string
69
     */
70 1
    public function getIdentifier()
71
    {
72 1
        return $this->identifier;
73
    }
74
75
    /**
76
     * @param string $identifier
77
     */
78 1
    public function setIdentifier($identifier)
79
    {
80 1
        $this->identifier = $identifier;
81 1
    }
82
83
    /**
84
     * Get the client's name.
85
     *
86
     * @return string
87
     */
88 3
    public function getName()
89
    {
90 3
        return $this->name;
91
    }
92
93
    /**
94
     * Returns the registered redirect URI (as a string).
95
     *
96
     * Alternatively return an indexed array of redirect URIs.
97
     *
98
     * @return string|string[]
99
     */
100 1
    public function getRedirectUri()
101
    {
102 1
        return $this->redirectUri;
103
    }
104
105
    /**
106
     * @param string $name
107
     * @return Client
108
     */
109 3
    public function setName($name)
110
    {
111 3
        $this->name = $name;
112 3
        return $this;
113
    }
114
115
    /**
116
     * @param string|\string[] $redirectUri
117
     * @return Client
118
     */
119 1
    public function setRedirectUri($redirectUri)
120
    {
121 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...
122 1
        return $this;
123
    }
124
125
    /**
126
     * @return string
127
     */
128
    public function getSecret(): string
129
    {
130
        return $this->secret;
131
    }
132
133
    /**
134
     * @param string $secret
135
     * @return Client
136
     */
137
    public function setSecret(string $secret): Client
138
    {
139
        $this->secret = $secret;
140
        return $this;
141
    }
142
143
    /**
144
     * @return bool
145
     */
146
    public function isConfidential(): bool
147
    {
148
        return $this->confidential;
149
    }
150
151
    /**
152
     * @param bool $confidential
153
     * @return Client
154
     */
155
    public function setConfidential(bool $confidential): Client
156
    {
157
        $this->confidential = $confidential;
158
        return $this;
159
    }
160
161
    /**
162
     * @return string
163
     */
164
    public function getId(): string
165
    {
166
        return $this->id;
167
    }
168
169
    /**
170
     * @param string $id
171
     * @return Client
172
     */
173
    public function setId(string $id): Client
174
    {
175
        $this->id = $id;
176
        return $this;
177
    }
178
179
    /**
180
     * @return ArrayCollection
181
     */
182
    public function getScopes(): ArrayCollection
183
    {
184
        return $this->scopes;
185
    }
186
187
    /**
188
     * @param ArrayCollection $scopes
189
     * @return Client
190
     */
191
    public function setScopes(ArrayCollection $scopes): Client
192
    {
193
        $this->scopes = $scopes;
194
        return $this;
195
    }
196
}