Passed
Push — feature/job-builder/step-0 ( 323da6...a76dc5 )
by Tristan
15:33 queued 09:48
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\ValidIdRule;
7
use App\Models\Criteria;
8
9
class UpdateRatingGuideAnswer extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
1 ignored issue
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
15
     */
16
    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...
17
    {
18
        // originalParameter avoids type hinting that automagically transforms the id into the RatingGuideAnswer object
1 ignored issue
show
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
19
        //$answer = RatingGuideAnswer::find($this->route()->originalParameter('ratingGuideAnswer'));
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// $answer = RatingGuideAnswer::find($this->route()->originalParameter('ratingGuideAnswer'));" but found "//$answer = RatingGuideAnswer::find($this->route()->originalParameter('ratingGuideAnswer'));"
Loading history...
Coding Style introduced by
There should be no blank line after an inline comment.
Loading history...
20
21
        // The id parameter in the route is typehinted to magically become a RatingGuideAnswer object.
22
        $answer = $this->route('ratingGuideAnswer');
23
        return $answer && $this->user()->can('update', $answer);
24
    }
25
26
    /**
27
     * Get the validation rules that apply to the request.
28
     *
29
     * @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...
30
     */
31
    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...
32
    {
33
        return [
34
            // RatingGuideQUestionId shouldn't be updated after creation
35
            //'rating_guide_question_id' => ['required', new RatingGuideQuestionRule()],
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// 'rating_guide_question_id' => ['required', new RatingGuideQuestionRule()]," but found "//'rating_guide_question_id' => ['required', new RatingGuideQuestionRule()],"
Loading history...
36
            'criterion_id' => ['nullable', new ValidIdRule(Criteria::class)],
37
            'expected_answer' => 'nullable|string',
38
        ];
39
    }
40
}
41