PostComment::tableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
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\helpers\ArrayHelper;
12
13
/**
14
 * This is the model class for table "{{%post_comment}}".
15
 *
16
 * @property integer $post_id
17
 *
18
 * @property Post $commentPost
19
 *
20
 * @author Agiel K. Saputra <[email protected]>
21
 * @since 0.1.0
22
 */
23 View Code Duplication
class PostComment extends BaseComment
0 ignored issues
show
Duplication introduced by
This class 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...
24
{
25
    /**
26
     * @var string
27
     */
28
    public $post_title;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public static function tableName()
34
    {
35
        return '{{%post_comment}}';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function rules()
42
    {
43
        return ArrayHelper::merge(parent::rules(), [
44
            ['post_id', 'required'],
45
            ['post_id', 'integer'],
46
        ]);
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function attributeLabels()
53
    {
54
        return ArrayHelper::merge(parent::attributeLabels(), [
55
            'post_id' => Yii::t('writesdown', 'Comment to'),
56
            'post_title' => Yii::t('writesdown', 'Post Title'),
57
        ]);
58
    }
59
60
    /**
61
     * @return \yii\db\ActiveQuery
62
     */
63
    public function getCommentPost()
64
    {
65
        return $this->hasOne(Post::className(), ['id' => 'post_id']);
66
    }
67
}
68