Passed
Push — master ( 40e145...79d0e7 )
by Derek Stephen
02:48
created

Client   A

Complexity

Total Complexity 23

Size/Duplication

Total Lines 271
Duplicated Lines 0 %

Test Coverage

Coverage 37.93%

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 271
ccs 22
cts 58
cp 0.3793
rs 10
c 0
b 0
f 0
wmc 23

23 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfidential() 0 4 1
A setIcon() 0 3 1
A setScopes() 0 4 1
A setSecret() 0 4 1
A getIcon() 0 3 1
A setUser() 0 3 1
A getRedirectUri() 0 3 1
A getDescription() 0 3 1
A getIdentifier() 0 3 1
A getGrantType() 0 3 1
A getId() 0 3 1
A getScopes() 0 3 1
A setIdentifier() 0 3 1
A __construct() 0 3 1
A setId() 0 4 1
A getUser() 0 3 1
A getName() 0 3 1
A setRedirectUri() 0 4 1
A setName() 0 4 1
A setGrantType() 0 3 1
A setDescription() 0 3 1
A isConfidential() 0 3 1
A getSecret() 0 3 1
1
<?php
2
3
namespace OAuth;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use League\OAuth2\Server\Entities\ClientEntityInterface;
8
9
/**
10
 * @ORM\Entity(repositoryClass="OAuth\Repository\ClientRepository")
11
 * @ORM\Table(name="Client",uniqueConstraints={@ORM\UniqueConstraint(name="indentifier_idx", columns={"identifier"})})
12
 */
13
class Client implements ClientEntityInterface
14
{
15
    /**
16
     * @ORM\Id
17
     * @var string
18
     * @ORM\Column(type="integer", length=11)
19
     * @ORM\GeneratedValue
20
     */
21
    private $id;
22
23
    /**
24
     * @var string
25
     * @ORM\Column(type="string", length=40)
26
     */
27
    private $name;
28
29
    /**
30
     * @var string
31
     * @ORM\Column(type="string", length=255)
32
     */
33
    private $description;
34
35
    /**
36
     * @var string
37
     * @ORM\Column(type="string", length=100)
38
     */
39
    private $icon;
40
41
    /**
42
     * @var string
43
     * @ORM\Column(type="string", length=20)
44
     */
45
    private $grantType;
46
47
    /**
48
     * @var string|string[]
49
     * @ORM\Column(type="string", length=255)
50
     */
51
    private $redirectUri;
52
53
    /**
54
     * @var string
55
     * @ORM\Column(type="string", length=40)
56
     */
57
    private $identifier;
58
59
    /**
60
     * @var string
61
     * @ORM\Column(type="string", length=40, nullable=true)
62
     */
63
    private $secret;
64
65
    /**
66
     * @var bool $confidential
67
     * @ORM\Column(type="boolean")
68
     */
69
    private $confidential;
70
71
    /**
72
     * @var OAuthUser $user/**
73
     * @ORM\ManyToOne(targetEntity="OAuth\OAuthUser", cascade={"merge"})
74
     */
75
    private $user;
76
77
    /**
78
     * @var ArrayCollection $scopes
79
     * @ORM\ManyToMany(targetEntity="Scope")
80
     * @ORM\JoinTable(name="Client_Scope",
81
     *      joinColumns={@ORM\JoinColumn(name="client_id", referencedColumnName="id")},
82
     *      inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
83
     *      )
84
     */
85
    private $scopes;
86
87 5
    public function __construct()
88
    {
89 5
        $this->scopes = new ArrayCollection();
90 5
    }
91
92
    /**
93
     * @return string
94
     */
95 2
    public function getIdentifier()
96
    {
97 2
        return $this->identifier;
98
    }
99
100
    /**
101
     * @param string $identifier
102
     */
103 1
    public function setIdentifier($identifier)
104
    {
105 1
        $this->identifier = $identifier;
106 1
    }
107
108
    /**
109
     * Get the client's name.
110
     *
111
     * @return string
112
     */
113 3
    public function getName()
114
    {
115 3
        return $this->name;
116
    }
117
118
    /**
119
     * Returns the registered redirect URI (as a string).
120
     *
121
     * Alternatively return an indexed array of redirect URIs.
122
     *
123
     * @return string|string[]
124
     */
125 1
    public function getRedirectUri()
126
    {
127 1
        return $this->redirectUri;
128
    }
129
130
    /**
131
     * @param string $name
132
     * @return Client
133
     */
134 3
    public function setName($name)
135
    {
136 3
        $this->name = $name;
137 3
        return $this;
138
    }
139
140
    /**
141
     * @param string|\string[] $redirectUri
142
     * @return Client
143
     */
144 1
    public function setRedirectUri($redirectUri)
145
    {
146 1
        $this->redirectUri = $redirectUri;
147 1
        return $this;
148
    }
149
150
    /**
151
     * @return string
152
     */
153 2
    public function getSecret(): string
154
    {
155 2
        return $this->secret;
156
    }
157
158
    /**
159
     * @param string $secret
160
     * @return Client
161
     */
162
    public function setSecret(string $secret): Client
163
    {
164
        $this->secret = $secret;
165
        return $this;
166
    }
167
168
    /**
169
     * @return bool
170
     */
171 2
    public function isConfidential(): bool
172
    {
173 2
        return $this->confidential;
174
    }
175
176
    /**
177
     * @param bool $confidential
178
     * @return Client
179
     */
180
    public function setConfidential(bool $confidential): Client
181
    {
182
        $this->confidential = $confidential;
183
        return $this;
184
    }
185
186
    /**
187
     * @return string
188
     */
189
    public function getId(): string
190
    {
191
        return $this->id;
192
    }
193
194
    /**
195
     * @param string $id
196
     * @return Client
197
     */
198
    public function setId(string $id): Client
199
    {
200
        $this->id = $id;
201
        return $this;
202
    }
203
204
    /**
205
     * @return string
206
     */
207
    public function getDescription(): string
208
    {
209
        return $this->description;
210
    }
211
212
    /**
213
     * @param string $description
214
     */
215
    public function setDescription(string $description): void
216
    {
217
        $this->description = $description;
218
    }
219
220
    /**
221
     * @return string
222
     */
223
    public function getIcon(): string
224
    {
225
        return $this->icon;
226
    }
227
228
    /**
229
     * @param string $icon
230
     */
231
    public function setIcon(string $icon): void
232
    {
233
        $this->icon = $icon;
234
    }
235
236
    /**
237
     * @return string
238
     */
239
    public function getGrantType(): string
240
    {
241
        return $this->grantType;
242
    }
243
244
    /**
245
     * @param string $grantType
246
     */
247
    public function setGrantType(string $grantType): void
248
    {
249
        $this->grantType = $grantType;
250
    }
251
252
    /**
253
     * @return OAuthUser
254
     */
255
    public function getUser(): OAuthUser
256
    {
257
        return $this->user;
258
    }
259
260
    /**
261
     * @param OAuthUser $user
262
     */
263
    public function setUser(OAuthUser $user): void
264
    {
265
        $this->user = $user;
266
    }
267
268
    /**
269
     * @return ArrayCollection
270
     */
271
    public function getScopes(): ArrayCollection
272
    {
273
        return $this->scopes;
274
    }
275
276
    /**
277
     * @param ArrayCollection $scopes
278
     * @return Client
279
     */
280
    public function setScopes(ArrayCollection $scopes): Client
281
    {
282
        $this->scopes = $scopes;
283
        return $this;
284
    }
285
}