TermRelationship::getPost()   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\db\ActiveRecord;
12
13
/**
14
 * This is the model class for table "{{%term_relationship}}".
15
 *
16
 * @property integer $post_id
17
 * @property integer $term_id
18
 *
19
 * @property Post $post
20
 * @property Term $term
21
 *
22
 * @author  Agiel K. Saputra <[email protected]>
23
 * @since   0.1.0
24
 */
25 View Code Duplication
class TermRelationship extends ActiveRecord
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...
26
{
27
    /**
28
     * @inheritdoc
29
     */
30
    public static function tableName()
31
    {
32
        return '{{%term_relationship}}';
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function rules()
39
    {
40
        return [
41
            [['post_id', 'term_id'], 'required'],
42
            [['post_id', 'term_id'], 'integer'],
43
        ];
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function attributeLabels()
50
    {
51
        return [
52
            'post_id' => Yii::t('writesdown', 'Post ID'),
53
            'term_id' => Yii::t('writesdown', 'Term ID'),
54
        ];
55
    }
56
57
    /**
58
     * @return \yii\db\ActiveQuery
59
     */
60
    public function getPost()
61
    {
62
        return $this->hasOne(Post::className(), ['id' => 'post_id']);
63
    }
64
65
    /**
66
     * @return \yii\db\ActiveQuery
67
     */
68
    public function getTerm()
69
    {
70
        return $this->hasOne(Term::className(), ['id' => 'term_id']);
71
    }
72
}
73