UserProvider   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 28.57%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 64
ccs 4
cts 14
cp 0.2857
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 4 1
A getUser() 0 4 1
A find() 0 4 1
A getTypes() 0 6 1
A getTypeByName() 0 5 2
A getTypeName() 0 5 2
1
<?php
2
3
namespace app\models\entity;
4
5
/**
6
 * This is the model class for table "{{%user_provider}}"
7
 *
8
 * @property integer $id
9
 * @property integer $user_id
10
 * @property integer $type
11
 * @property string $profile_id
12
 * @property string $profile_url
13
 * @property string $access_token
14
 * @property string $access_token_secret
15
 *
16
 * @property User $user
17
 */
18
class UserProvider extends \yii\db\ActiveRecord
19
{
20
    const TYPE_FACEBOOK = 1;
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public static function tableName()
26
    {
27 10
        return '{{%user_provider}}';
28
    }
29 10
30
    /**
31
     * @return \yii\db\ActiveQuery
32
     */
33
    public function getUser()
34
    {
35
        return $this->hasOne(User::class, ['id' => 'user_id']);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     * @return \app\models\query\UserProviderQuery The active query used by this AR class
41
     */
42
    public static function find()
43
    {
44 10
        return new \app\models\query\UserProviderQuery(get_called_class());
45
    }
46 10
47
    /**
48
     * Get types
49
     *
50
     * @return array
51
     */
52
    public static function getTypes(): array
53
    {
54
        return [
55
            self::TYPE_FACEBOOK => 'facebook',
56
        ];
57
    }
58
59
    /**
60
     * Get type by id
61
     *
62
     * @return string $name
63
     * @return int
64
     */
65
    public static function getTypeByName(string $name): int
66
    {
67
        $types = array_flip(self::getTypes());
68
        return isset($types[$name]) ? $types[$name] : false;
69
    }
70
71
    /**
72
     * Get type name
73
     *
74
     * @return string
75
     */
76
    public function getTypeName(): string
77
    {
78
        $types = self::getTypes();
79
        return isset($types[$this->type]) ? $types[$this->type] : false;
80
    }
81
}
82