Completed
Push — feature/screening-plan-redux ( d8e1fd...f4e53a )
by Tristan
20:23 queued 20:19
created

RatingGuideAnswer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 12
dl 0
loc 47
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A criterion() 0 3 1
A rating_guide_question() 0 3 1
A setCriterionIdAttribute() 0 6 2
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class RatingGuideQuestion
7
 *
8
 * @property int $id
9
 * @property int $rating_guide_question_id
10
 * @property int $criterion_id
11
 * @property string $expected_answer
12
 * @property \Jenssegers\Date\Date $created_at
13
 * @property \Jenssegers\Date\Date $updated_at
14
 *
15
 * @property \App\Models\RatingGuideQuestion $rating_guide_question
16
 * @property \App\Models\Criteria $criterion
17
 */
18
class RatingGuideAnswer extends BaseModel
19
{
20
    /**
21
     * The columns that can be filled with mass-assignment
22
     *
23
     * @var string[]
24
     */
25
    protected $fillable = [
26
        'rating_guide_question_id',
27
        'criterion_id',
28
        'expected_answer',
29
        'question'
30
    ];
31
32
    /**
33
     * Mutator for criterion_id. Save NULL instead of empty strings.
34
     *
35
     * @param string $value Criterion Id, or empty string
1 ignored issue
show
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
36
     * @return void
37
     */
38
    public function setCriterionIdAttribute(string $value): void
39
    {
40
        if (empty($value)) { // will check for empty string, null values
41
            $this->attributes['criterion_id'] = null;
42
        } else {
43
            $this->attributes['criterion_id'] = $value;
44
        }
45
    }
46
47
    /**
48
     * Get the RatingGuideQuestion relation.
49
     *
50
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
51
     */
52
    public function rating_guide_question(): \Illuminate\Database\Eloquent\Relations\BelongsTo
0 ignored issues
show
Coding Style introduced by
Method name "RatingGuideAnswer::rating_guide_question" is not in camel caps format
Loading history...
53
    {
54
        return $this->belongsTo(\App\Models\RatingGuideQuestion::class);
55
    }
56
57
    /**
58
     * Get the Criteria relation.
59
     *
60
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
61
     */
62
    public function criterion(): \Illuminate\Database\Eloquent\Relations\BelongsTo
63
    {
64
        return $this->belongsTo(\App\Models\Criteria::class, 'criterion_id');
65
    }
66
}
67