Passed
Push — master ( e9c9be...dec7df )
by Derek Stephen
03:02
created

Client::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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