WithSurveyModel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSurvey() 0 3 1
A rules() 0 6 1
1
<?php
2
3
namespace dameter\abstracts;
4
5
use dameter\abstracts\models\BaseSurvey;
6
7
/**
8
 * Class WithSurveyModel
9
 * @property integer $survey_id
10
 *
11
 * @package dameter\abstracts
12
 * @property BaseSurvey $survey
13
 *
14
 * @author Tõnis Ormisson <[email protected]>
15
 */
16
class WithSurveyModel extends DActiveRecord
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function rules()
22
    {
23
        return [
24
            [['survey_id'], 'required'],
25
            [['survey_id'], 'integer'],
26
            [['survey_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseSurvey::class, 'targetAttribute' => ['survey_id' => 'survey_id']],
27
        ];
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getSurvey()
34
    {
35
        return $this->hasOne(BaseSurvey::class);
36
    }
37
38
}