Passed
Push — task/screening-plan-performanc... ( 402c06...124a4a )
by Tristan
14:18 queued 09:02
created

UpdateRatingGuideAnswer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 29
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 7 1
A authorize() 0 8 2
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use App\Services\Validation\Rules\RatingGuideQuestionRule;
7
use App\Services\Validation\Rules\CriterionRule;
8
use App\Models\RatingGuideAnswer;
9
10
class UpdateRatingGuideAnswer extends FormRequest
11
{
12
    /**
13
     * Determine if the user is authorized to make this request.
14
     *
15
     * @return bool
1 ignored issue
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
16
     */
17
    public function authorize()
0 ignored issues
show
introduced by
Method \App\Http\Requests\UpdateRatingGuideAnswer::authorize() does not have return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
18
    {
19
        // originalParameter avoids type hinting that automagically transforms the id into the RatingGuideAnswer object
20
        //$answer = RatingGuideAnswer::find($this->route()->originalParameter('ratingGuideAnswer'));
21
22
        // The id parameter in the route is typehinted to magically become a RatingGuideAnswer object.
23
        $answer = $this->route('ratingGuideAnswer');
24
        return $answer && $this->user()->can('update', $answer);
25
    }
26
27
    /**
28
     * Get the validation rules that apply to the request.
29
     *
30
     * @return array
0 ignored issues
show
introduced by
@return annotation of method \App\Http\Requests\UpdateRatingGuideAnswer::rules() does not specify type hint for items of its traversable return value.
Loading history...
31
     */
32
    public function rules()
0 ignored issues
show
introduced by
Method \App\Http\Requests\UpdateRatingGuideAnswer::rules() does not have return type hint for its return value but it should be possible to add it based on @return annotation "array".
Loading history...
33
    {
34
        return [
35
            // RatingGuideQUestionId shouldn't be updated after creation
36
            //'rating_guide_question_id' => ['required', new RatingGuideQuestionRule()],
37
            'criterion_id' => ['nullable', new CriterionRule()],
38
            'expected_answer' => 'nullable|string',
39
        ];
40
    }
41
}
42