Completed
Push — master ( 196bfd...794470 )
by Tõnis
02:15
created

ModelCondition   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 42
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getQuestionGroup() 0 3 1
A getAnswer() 0 3 1
A rules() 0 7 1
A getQuestion() 0 3 1
A getParent() 0 3 1
1
<?php
2
3
namespace dameter\abstracts\models;
4
5
6
use dameter\abstracts\ManyToManyModel;
7
use yii\base\NotSupportedException;
8
9
/**
10
 * Class ModelCondition
11
 * @package dameter\abstracts\models
12
 * @author Tõnis Ormisson <[email protected]>
13
 *
14
 * @property integer $condition_id
15
 * @property integer $question_id
16
 * @property integer $question_group_id
17
 * @property integer $answer_id
18
 *
19
 * @property BaseQuestionGroup $questionGroup
20
 * @property BaseQuestion $question
21
 * @property BaseAnswer $answer
22
 *
23
 * @property Condition $child
24
 */
25
class ModelCondition extends ManyToManyModel
26
{
27
    public static $childClass = Condition::class;
28
29
    /** {@inheritdoc} */
30
    public function rules()
31
    {
32
        return array_merge(parent::rules(), [
33
            [['question_group_id', 'question_id', 'answer_id'], 'integer'],
34
            [['question_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseQuestionGroup::class, 'targetAttribute' => ['question_group_id' => 'question_group_id']],
35
            [['question_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseQuestion::class, 'targetAttribute' => ['question_id' => 'question_id']],
36
            [['answer_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseAnswer::class, 'targetAttribute' => ['answer_id' => 'answer_id']],
37
        ]);
38
    }
39
40
    /**
41
     * @return \yii\db\ActiveQuery
42
     */
43
    public function getQuestionGroup()
44
    {
45
        return $this->hasOne(BaseQuestionGroup::class);
46
    }
47
48
    /**
49
     * @return \yii\db\ActiveQuery
50
     */
51
    public function getQuestion()
52
    {
53
        return $this->hasOne(BaseQuestion::class);
54
    }
55
56
    /**
57
     * @return \yii\db\ActiveQuery
58
     */
59
    public function getAnswer()
60
    {
61
        return $this->hasOne(BaseAnswer::class);
62
    }
63
64
    public function getParent()
65
    {
66
        throw new NotSupportedException();
67
    }
68
69
70
71
}