PostMeta::attributeLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 * @link http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license http://www.writesdown.com/license/
6
 */
7
8
namespace common\models;
9
10
use Yii;
11
use yii\db\ActiveRecord;
12
13
/**
14
 * This is the model class for table "{{%post_meta}}".
15
 *
16
 * @property integer $id
17
 * @property integer $post_id
18
 * @property string $name
19
 * @property string $value
20
 *
21
 * @property Post $post
22
 *
23
 * @author Agiel K. Saputra <[email protected]>
24
 * @since 0.1.0
25
 */
26
class PostMeta extends ActiveRecord
27
{
28
    /**
29
     * @inheritdoc
30
     */
31
    public static function tableName()
32
    {
33
        return '{{%post_meta}}';
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 View Code Duplication
    public function rules()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        return [
42
            [['post_id', 'name', 'value'], 'required'],
43
            ['post_id', 'integer'],
44
            ['value', 'string'],
45
            ['name', 'string', 'max' => 255],
46
        ];
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52 View Code Duplication
    public function attributeLabels()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        return [
55
            'id' => Yii::t('writesdown', 'ID'),
56
            'post_id' => Yii::t('writesdown', 'Post ID'),
57
            'name' => Yii::t('writesdown', 'Meta Name'),
58
            'value' => Yii::t('writesdown', 'Meta Value'),
59
        ];
60
    }
61
62
    /**
63
     * @return \yii\db\ActiveQuery
64
     */
65
    public function getPost()
66
    {
67
        return $this->hasOne(Post::className(), ['id' => 'post_id']);
68
    }
69
}
70