Completed
Push — master ( 4b9759...190a84 )
by Neomerx
11:49
created

DatabaseSchema::getTokensClientIdentityColumn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Limoncello\Passport\Entities;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Passport\Contracts\Entities\DatabaseSchemaInterface;
20
21
/**
22
 * @package Limoncello\Passport
23
 *
24
 * @SuppressWarnings(PHPMD)
25
 */
26
class DatabaseSchema implements DatabaseSchemaInterface
27
{
28
    /** Table name */
29
    const TABLE_CLIENTS = 'oauth_clients';
30
31
    /** View name */
32
    const VIEW_CLIENTS = 'vw_oauth_clients';
33
34
    /** Table name */
35
    const TABLE_CLIENTS_SCOPES = 'oauth_clients_scopes';
36
37
    /** Table name */
38
    const TABLE_REDIRECT_URIS = 'oauth_redirect_uris';
39
40
    /** Table name */
41
    const TABLE_SCOPES = 'oauth_scopes';
42
43
    /** Table name */
44
    const TABLE_TOKENS = 'oauth_tokens';
45
46
    /** View name */
47
    const VIEW_TOKENS = 'vw_oauth_tokens';
48
49
    /** Table name */
50
    const TABLE_TOKENS_SCOPES = 'oauth_tokens_scopes';
51
52
    /** View name */
53
    const VIEW_USERS = 'vw_oauth_users';
54
55
    /** Field name */
56
    const CLIENTS_SCOPES_FIELD_ID = 'clients_scopes_id';
57
58
    /** Field name */
59
    const TOKENS_SCOPES_FIELD_ID = 'tokens_scopes_id';
60
61
    /** View name */
62
    const VIEW_PASSPORT = 'vw_oauth_passport';
63
64
    /**
65
     * @var string|null
66
     */
67
    private $usersTableName;
68
69
    /**
70
     * @var string|null
71
     */
72
    private $usersIdColumn;
73
74
    /**
75
     * @param null|string $usersTableName
76
     * @param null|string $usersIdColumn
77
     */
78 39
    public function __construct(string $usersTableName = null, string $usersIdColumn = null)
79
    {
80 39
        $this->usersTableName = $usersTableName;
81 39
        $this->usersIdColumn  = $usersIdColumn;
82
    }
83
84
    /**
85
     * @inheritdoc
86
     */
87 33
    public function getClientsTable(): string
88
    {
89 33
        return static::TABLE_CLIENTS;
90
    }
91
92
    /**
93
     * @inheritdoc
94
     */
95 3
    public function getClientsView(): string
96
    {
97 3
        return static::VIEW_CLIENTS;
98
    }
99
100
    /**
101
     * @inheritdoc
102
     */
103 2
    public function getClientsViewScopesColumn(): string
104
    {
105 2
        return Client::FIELD_SCOPES;
106
    }
107
108
    /**
109
     * @inheritdoc
110
     */
111 2
    public function getClientsViewRedirectUrisColumn(): string
112
    {
113 2
        return Client::FIELD_REDIRECT_URIS;
114
    }
115
116
    /**
117
     * @inheritdoc
118
     */
119 32
    public function getClientsIdentityColumn(): string
120
    {
121 32
        return Client::FIELD_ID;
122
    }
123
124
    /**
125
     * @inheritdoc
126
     */
127 31
    public function getClientsNameColumn(): string
128
    {
129 31
        return Client::FIELD_NAME;
130
    }
131
132
    /**
133
     * @inheritdoc
134
     */
135 31
    public function getClientsDescriptionColumn(): string
136
    {
137 31
        return Client::FIELD_DESCRIPTION;
138
    }
139
140
    /**
141
     * @inheritdoc
142
     */
143 31
    public function getClientsCredentialsColumn(): string
144
    {
145 31
        return Client::FIELD_CREDENTIALS;
146
    }
147
148
    /**
149
     * @inheritdoc
150
     */
151 31
    public function getClientsIsConfidentialColumn(): string
152
    {
153 31
        return Client::FIELD_IS_CONFIDENTIAL;
154
    }
155
156
    /**
157
     * @inheritdoc
158
     */
159 31
    public function getClientsIsScopeExcessAllowedColumn(): string
160
    {
161 31
        return Client::FIELD_IS_SCOPE_EXCESS_ALLOWED;
162
    }
163
164
    /**
165
     * @inheritdoc
166
     */
167 31
    public function getClientsIsUseDefaultScopeColumn(): string
168
    {
169 31
        return Client::FIELD_IS_USE_DEFAULT_SCOPE;
170
    }
171
172
    /**
173
     * @inheritdoc
174
     */
175 31
    public function getClientsIsCodeGrantEnabledColumn(): string
176
    {
177 31
        return Client::FIELD_IS_CODE_GRANT_ENABLED;
178
    }
179
180
    /**
181
     * @inheritdoc
182
     */
183 31
    public function getClientsIsImplicitGrantEnabledColumn(): string
184
    {
185 31
        return Client::FIELD_IS_IMPLICIT_GRANT_ENABLED;
186
    }
187
188
    /**
189
     * @inheritdoc
190
     */
191 31
    public function getClientsIsPasswordGrantEnabledColumn(): string
192
    {
193 31
        return Client::FIELD_IS_PASSWORD_GRANT_ENABLED;
194
    }
195
196
    /**
197
     * @inheritdoc
198
     */
199 31
    public function getClientsIsClientGrantEnabledColumn(): string
200
    {
201 31
        return Client::FIELD_IS_CLIENT_GRANT_ENABLED;
202
    }
203
204
    /**
205
     * @inheritdoc
206
     */
207 31
    public function getClientsIsRefreshGrantEnabledColumn(): string
208
    {
209 31
        return Client::FIELD_IS_REFRESH_GRANT_ENABLED;
210
    }
211
212
    /**
213
     * @inheritdoc
214
     */
215 31
    public function getClientsCreatedAtColumn(): string
216
    {
217 31
        return Client::FIELD_CREATED_AT;
218
    }
219
220
    /**
221
     * @inheritdoc
222
     */
223 31
    public function getClientsUpdatedAtColumn(): string
224
    {
225 31
        return Client::FIELD_UPDATED_AT;
226
    }
227
228
    /**
229
     * @inheritdoc
230
     */
231 33
    public function getClientsScopesTable(): string
232
    {
233 33
        return static::TABLE_CLIENTS_SCOPES;
234
    }
235
236
    /**
237
     * @inheritdoc
238
     */
239 31
    public function getClientsScopesIdentityColumn(): string
240
    {
241 31
        return static::CLIENTS_SCOPES_FIELD_ID;
242
    }
243
244
    /**
245
     * @inheritdoc
246
     */
247 32
    public function getClientsScopesClientIdentityColumn(): string
248
    {
249 32
        return Client::FIELD_ID;
250
    }
251
252
    /**
253
     * @inheritdoc
254
     */
255 31
    public function getClientsScopesScopeIdentityColumn(): string
256
    {
257 31
        return Scope::FIELD_ID;
258
    }
259
260
    /**
261
     * @inheritdoc
262
     */
263 34
    public function getRedirectUrisTable(): string
264
    {
265 34
        return static::TABLE_REDIRECT_URIS;
266
    }
267
268
    /**
269
     * @inheritdoc
270
     */
271 31
    public function getRedirectUrisIdentityColumn(): string
272
    {
273 31
        return RedirectUri::FIELD_ID;
274
    }
275
276
    /**
277
     * @inheritdoc
278
     */
279 32
    public function getRedirectUrisClientIdentityColumn(): string
280
    {
281 32
        return RedirectUri::FIELD_ID_CLIENT;
282
    }
283
284
    /**
285
     * @inheritdoc
286
     */
287 32
    public function getRedirectUrisValueColumn(): string
288
    {
289 32
        return RedirectUri::FIELD_VALUE;
290
    }
291
292
    /**
293
     * @inheritdoc
294
     */
295 31
    public function getRedirectUrisCreatedAtColumn(): string
296
    {
297 31
        return RedirectUri::FIELD_CREATED_AT;
298
    }
299
300
    /**
301
     * @inheritdoc
302
     */
303 31
    public function getRedirectUrisUpdatedAtColumn(): string
304
    {
305 31
        return RedirectUri::FIELD_UPDATED_AT;
306
    }
307
308
    /**
309
     * @inheritdoc
310
     */
311 33
    public function getScopesTable(): string
312
    {
313 33
        return static::TABLE_SCOPES;
314
    }
315
316
    /**
317
     * @inheritdoc
318
     */
319 33
    public function getScopesIdentityColumn(): string
320
    {
321 33
        return Scope::FIELD_ID;
322
    }
323
324
    /**
325
     * @inheritdoc
326
     */
327 32
    public function getScopesDescriptionColumn(): string
328
    {
329 32
        return Scope::FIELD_DESCRIPTION;
330
    }
331
332
    /**
333
     * @inheritdoc
334
     */
335 32
    public function getScopesCreatedAtColumn(): string
336
    {
337 32
        return Scope::FIELD_CREATED_AT;
338
    }
339
340
    /**
341
     * @inheritdoc
342
     */
343 32
    public function getScopesUpdatedAtColumn(): string
344
    {
345 32
        return Scope::FIELD_UPDATED_AT;
346
    }
347
348
    /**
349
     * @inheritdoc
350
     */
351 33
    public function getTokensTable(): string
352
    {
353 33
        return static::TABLE_TOKENS;
354
    }
355
356
    /**
357
     * @inheritdoc
358
     */
359 4
    public function getTokensView(): string
360
    {
361 4
        return static::VIEW_TOKENS;
362
    }
363
364
    /**
365
     * @inheritdoc
366
     */
367 4
    public function getTokensViewScopesColumn(): string
368
    {
369 4
        return Token::FIELD_SCOPES;
370
    }
371
372
    /**
373
     * @inheritdoc
374
     */
375 33
    public function getTokensIdentityColumn(): string
376
    {
377 33
        return Token::FIELD_ID;
378
    }
379
380
    /**
381
     * @inheritdoc
382
     */
383 33
    public function getTokensIsEnabledColumn(): string
384
    {
385 33
        return Token::FIELD_IS_ENABLED;
386
    }
387
388
    /**
389
     * @inheritdoc
390
     */
391 31
    public function getTokensIsScopeModified(): string
392
    {
393 31
        return Token::FIELD_IS_SCOPE_MODIFIED;
394
    }
395
396
    /**
397
     * @inheritdoc
398
     */
399 32
    public function getTokensClientIdentityColumn(): string
400
    {
401 32
        return Token::FIELD_ID_CLIENT;
402
    }
403
404
    /**
405
     * @inheritdoc
406
     */
407 33
    public function getTokensUserIdentityColumn(): string
408
    {
409 33
        return Token::FIELD_ID_USER;
410
    }
411
412
    /**
413
     * @inheritdoc
414
     */
415 31
    public function getTokensRedirectUriColumn(): string
416
    {
417 31
        return Token::FIELD_REDIRECT_URI;
418
    }
419
420
    /**
421
     * @inheritdoc
422
     */
423 31
    public function getTokensCodeColumn(): string
424
    {
425 31
        return Token::FIELD_CODE;
426
    }
427
428
    /**
429
     * @inheritdoc
430
     */
431 33
    public function getTokensValueColumn(): string
432
    {
433 33
        return Token::FIELD_VALUE;
434
    }
435
436
    /**
437
     * @inheritdoc
438
     */
439 31
    public function getTokensTypeColumn(): string
440
    {
441 31
        return Token::FIELD_TYPE;
442
    }
443
444
    /**
445
     * @inheritdoc
446
     */
447 31
    public function getTokensRefreshColumn(): string
448
    {
449 31
        return Token::FIELD_REFRESH;
450
    }
451
452
    /**
453
     * @inheritdoc
454
     */
455 31
    public function getTokensCodeCreatedAtColumn(): string
456
    {
457 31
        return Token::FIELD_CODE_CREATED_AT;
458
    }
459
460
    /**
461
     * @inheritdoc
462
     */
463 33
    public function getTokensValueCreatedAtColumn(): string
464
    {
465 33
        return Token::FIELD_VALUE_CREATED_AT;
466
    }
467
468
    /**
469
     * @inheritdoc
470
     */
471 31
    public function getTokensRefreshCreatedAtColumn(): string
472
    {
473 31
        return Token::FIELD_REFRESH_CREATED_AT;
474
    }
475
476
    /**
477
     * @inheritdoc
478
     */
479 33
    public function getTokensScopesTable(): string
480
    {
481 33
        return static::TABLE_TOKENS_SCOPES;
482
    }
483
484
    /**
485
     * @inheritdoc
486
     */
487 31
    public function getTokensScopesIdentityColumn(): string
488
    {
489 31
        return static::TOKENS_SCOPES_FIELD_ID;
490
    }
491
492
    /**
493
     * @inheritdoc
494
     */
495 32
    public function getTokensScopesTokenIdentityColumn(): string
496
    {
497 32
        return Token::FIELD_ID;
498
    }
499
500
    /**
501
     * @inheritdoc
502
     */
503 32
    public function getTokensScopesScopeIdentityColumn(): string
504
    {
505 32
        return Scope::FIELD_ID;
506
    }
507
508
    /**
509
     * @inheritdoc
510
     */
511 3
    public function getUsersView(): ?string
512
    {
513 3
        return static::VIEW_USERS;
514
    }
515
516
    /**
517
     * @inheritdoc
518
     */
519 32
    public function getUsersTable(): ?string
520
    {
521 32
        return $this->usersTableName;
522
    }
523
524
    /**
525
     * @inheritdoc
526
     */
527 32
    public function getUsersIdentityColumn(): ?string
528
    {
529 32
        return $this->usersIdColumn;
530
    }
531
532
    /**
533
     * @inheritdoc
534
     */
535 4
    public function getPassportView(): ?string
536
    {
537 4
        return static::VIEW_PASSPORT;
538
    }
539
}
540