Completed
Push — master ( c064eb...85769a )
by Igor
03:38
created

UserProfile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 72.21%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 47
ccs 13
cts 18
cp 0.7221
rs 10

5 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 getFiles() 0 6 1
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use app\models\File;
7
8
/**
9
 * This is the model class for table "user_profile".
10
 *
11
 * @property integer $user_id
12
 * @property string $full_name
13
 * @property string $photo
14
 * @property string $birth_day
15
 */
16
class UserProfile extends \yii\db\ActiveRecord
17
{
18 10
    public function __construct($config = [])
19
    {
20 10
        $this->attachBehavior(
21 10
            'fileManager',
22 10
            require Yii::getAlias('@app/models/behaviors/user-profile/filemanager.php')
23
        );
24 10
        parent::__construct($config);
25 10
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 28
    public static function tableName()
31
    {
32 28
        return 'user_profile';
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 1
    public function attributeLabels()
39
    {
40
        return [
41 1
            'user_id' => Yii::t('app', 'User'),
42 1
            'full_name' => Yii::t('app', 'Full Name'),
43 1
            'photo' => Yii::t('app', 'Photo'),
44 1
            'birth_day' => Yii::t('app', 'Birth Day'),
45
        ];
46
    }
47
48
    /**
49
     * @return \yii\db\ActiveQuery
50
     */
51
    public function getUser()
52
    {
53
        return $this->hasOne(User::class, ['id' => 'user_id']);
54
    }
55
56
    public function getFiles($callable = null)
57
    {
58
        return $this
59
            ->hasMany(File::class, ['id' => 'file_id'])
60
            ->viaTable('user_profiles_files', ['user_id' => 'user_id'], $callable);
61
    }
62
}
63