Passed
Push — feature/job-builder/step-01 ( a153c5...990c2a )
by Tristan
15:40 queued 09:50
created

UpdateRatingGuideAnswer::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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