OauthRefreshTokens::tableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\oauth2server\models;
4
5
use Yii;
6
use yii\db\{ActiveQuery, ActiveRecord};
7
8
/**
9
 * This is the model class for table "oauth_refresh_tokens".
10
 *
11
 * @property string $refresh_token
12
 * @property string $client_id
13
 * @property integer $user_id
14
 * @property string $expires
15
 * @property string $scope
16
 *
17
 * @property OauthClients $client
18
 */
19
class OauthRefreshTokens extends ActiveRecord
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public static function tableName(): string
25
    {
26
        return '{{%oauth_refresh_tokens}}';
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function rules(): array
33
    {
34
        return [
35
            [['refresh_token', 'client_id', 'expires'], 'required'],
36
            [['user_id'], 'integer'],
37
            [['expires'], 'safe'],
38
            [['refresh_token'], 'string', 'max' => 40],
39
            [['client_id'], 'string', 'max' => 32],
40
            [['scope'], 'string', 'max' => 2000]
41
        ];
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function attributeLabels(): array
48
    {
49
        return [
50
            'refresh_token' => 'Refresh Token',
51
            'client_id' => 'Client ID',
52
            'user_id' => 'User ID',
53
            'expires' => 'Expires',
54
            'scope' => 'Scope',
55
        ];
56
    }
57
58
    /**
59
     * @return ActiveQuery
60
     */
61
    public function getClient(): ActiveQuery
62
    {
63
        return $this->hasOne(
64
            OauthClients::class,
65
            ['client_id' => 'client_id']
66
        );
67
    }
68
}
69