Completed
Push — master ( 5b8bc2...b011b0 )
by Tõnis
02:00
created

BaseQuestion::getAnswers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dameter\abstracts\models;
4
5
use dameter\abstracts\validators\VariableNameValidator;
6
7
8
/**
9
 * Class BaseQuestion
10
 * @property integer $question_id
11
 * @property integer $survey_id
12
 * @property string $code Question code is like eg a variable name in SPSS. A relatively short no-spaces survey-wide unique identifier
13
 *
14
 * @property BaseAnswer[] $answers
15
 *
16
 * @package dameter\abstracts\models
17
 * @author Tõnis Ormisson <[email protected]>
18
 */
19
abstract class BaseQuestion extends WithSurveyModel
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function rules()
25
    {
26
        return array_merge(parent::rules(), [
27
            [['code'], 'required'],
28
            [['code'], VariableNameValidator::class],
29
        ]);
30
    }
31
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getAnswers()
37
    {
38
        return $this->hasMany(BaseSurvey::class);
39
    }
40
41
42
}