Passed
Push — feature/job-builder/step-03-ui ( dabf2e...dabf2e )
by Xander
20:05 queued 13s
created

RatingGuideAnswer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 46
ccs 0
cts 9
cp 0
rs 10

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
    ];
30
31
    /**
32
     * Mutator for criterion_id. Save NULL instead of empty strings.
33
     *
34
     * @param string|null $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...
35
     * @return void
36
     */
37
    public function setCriterionIdAttribute($value): void
0 ignored issues
show
introduced by
Method \App\Models\RatingGuideAnswer::setCriterionIdAttribute() does not have parameter type hint for its parameter $value but it should be possible to add it based on @param annotation "string|null".
Loading history...
38
    {
39
        if (empty($value)) { // will check for empty string, null values
1 ignored issue
show
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
40
            $this->attributes['criterion_id'] = null;
41
        } else {
42
            $this->attributes['criterion_id'] = $value;
43
        }
44
    }
45
46
    /**
47
     * Get the RatingGuideQuestion relation.
48
     *
49
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
50
     */
51
    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...
52
    {
53
        return $this->belongsTo(\App\Models\RatingGuideQuestion::class);
54
    }
55
56
    /**
57
     * Get the Criteria relation.
58
     *
59
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
60
     */
61
    public function criterion(): \Illuminate\Database\Eloquent\Relations\BelongsTo
62
    {
63
        return $this->belongsTo(\App\Models\Criteria::class, 'criterion_id');
64
    }
65
}
66