Completed
Push — master ( d0bd4d...b4b0fd )
by Igor
23:04
created

UserProfile   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 59
c 0
b 0
f 0
ccs 10
cts 20
cp 0.5
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A tableName() 0 4 1
A attributeLabels() 0 9 1
A getUser() 0 4 1
A getPhotoFile() 0 6 1
A find() 0 4 1
1
<?php
2
3
namespace app\models\entity;
4
5
use Yii;
6
7
/**
8
 * This is the model class for table "{{%user_profile}}".
9
 *
10
 * @property integer $user_id
11
 * @property string $full_name
12
 * @property string $photo
13
 * @property string $birth_day
14
 *
15
 * @property User $user
16
 * @property File $photoFile
17
 */
18
class UserProfile extends \yii\db\ActiveRecord
19
{
20 9
    public function __construct($config = [])
21
    {
22 9
        $this->attachBehavior(
23 9
            'fileManager',
24 9
            require Yii::getAlias('@app/config/behaviors/user-profile/filemanager.php')
25
        );
26 9
        parent::__construct($config);
27 9
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 26
    public static function tableName()
33
    {
34 26
        return '{{%user_profile}}';
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function attributeLabels()
41
    {
42
        return [
43
            'user_id' => Yii::t('app', 'User'),
44
            'full_name' => Yii::t('app', 'Full Name'),
45
            'photo' => Yii::t('app', 'Photo'),
46
            'birth_day' => Yii::t('app', 'Birth Day'),
47
        ];
48
    }
49
50
    /**
51
     * @return \yii\db\ActiveQuery
52
     */
53
    public function getUser()
54
    {
55
        return $this->hasOne(User::class, ['id' => 'user_id']);
56
    }
57
58
    /**
59
     * @return \yii\db\ActiveQuery
60
     */
61
    public function getPhotoFile()
62
    {
63
        return $this
64
            ->hasOne(File::class, ['id' => 'file_id'])
65
            ->viaTable('{{%user_profile_to_file}}', ['user_id' => 'user_id']);
66
    }
67
68
    /**
69
     * @inheritdoc
70
     * @return \query\UserProfileQuery the active query used by this AR class.
71
     */
72 11
    public static function find()
73
    {
74 11
        return new \app\models\query\UserProfileQuery(get_called_class());
75
    }
76
}
77