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

BaseQuestion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 5 1
A getAnswers() 0 3 1
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
}