Completed
Push — master ( 69ec8b...199d88 )
by Tõnis
02:10
created

BaseAnswer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getQuestion() 0 3 1
A rules() 0 6 1
A getTexts() 0 3 1
1
<?php
2
3
namespace dameter\abstracts\models;
4
5
use dameter\abstracts\interfaces\WithLanguageSettingInterface;
6
7
8
/**
9
 * Class BaseAnswer
10
 * @property integer $answer_id
11
 * @property integer $question_id
12
 * @property integer $survey_id
13
 *
14
 * @property   BaseQuestion $question
15
 *
16
 * @package dameter\abstracts\models
17
 * @author Tõnis Ormisson <[email protected]>
18
 */
19
class BaseAnswer extends WithSurveyModel implements WithLanguageSettingInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function rules()
25
    {
26
        return array_merge(parent::rules(), [
27
            [['question_id', 'code'], 'required'],
28
            [['question_id'], 'integer'],
29
            [['code'], 'string', 'max' => 64],
30
        ]);
31
    }
32
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function getQuestion()
38
    {
39
        return $this->hasOne(BaseQuestion::class);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getTexts()
46
    {
47
        return $this->hasMany(AnswerText::class);
48
    }
49
50
}