AccountCategory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getCategory() 0 3 1
A rules() 0 9 1
A getAccount() 0 3 1
A tableName() 0 3 1
A getUser() 0 3 1
A attributeLabels() 0 6 1
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use yii\db\ActiveRecord;
7
8
/**
9
 * This is the model class for table "account_category".
10
 *
11
 * @property int $account_id
12
 * @property int $category_id
13
 * @property int $user_id
14
 *
15
 * @property Account $account
16
 * @property Category $category
17
 * @property User $user
18
 */
19
class AccountCategory extends ActiveRecord
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public static function tableName()
25
    {
26
        return 'account_category';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function rules()
33
    {
34
        return [
35
            [['account_id', 'category_id', 'user_id'], 'required'],
36
            [['account_id', 'category_id', 'user_id'], 'integer'],
37
            [['account_id', 'category_id', 'user_id'], 'unique', 'targetAttribute' => ['account_id', 'category_id', 'user_id']],
38
            [['account_id'], 'exist', 'skipOnError' => true, 'targetClass' => Account::class, 'targetAttribute' => ['account_id' => 'id']],
39
            [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::class, 'targetAttribute' => ['category_id' => 'id']],
40
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']],
41
        ];
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function attributeLabels()
48
    {
49
        return [
50
            'account_id' => Yii::t('app', 'Account ID'),
51
            'category_id' => Yii::t('app', 'Category ID'),
52
            'user_id' => Yii::t('app', 'User ID'),
53
        ];
54
    }
55
56
    /**
57
     * @return \yii\db\ActiveQuery
58
     */
59
    public function getAccount()
60
    {
61
        return $this->hasOne(Account::class, ['id' => 'account_id']);
62
    }
63
64
    /**
65
     * @return \yii\db\ActiveQuery
66
     */
67
    public function getCategory()
68
    {
69
        return $this->hasOne(Category::class, ['id' => 'category_id']);
70
    }
71
72
    /**
73
     * @return \yii\db\ActiveQuery
74
     */
75
    public function getUser()
76
    {
77
        return $this->hasOne(User::class, ['id' => 'user_id']);
78
    }
79
}
80