Passed
Push — feature/word_counter ( c4ec23...76dc11 )
by Yonathan
16:47
created

UpdateManager::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Lookup\Frequency;
8
use App\Models\Lookup\Department;
9
10
class UpdateManager 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\UpdateManager::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
        return true;
20
    }
21
22
    /**
23
     * Get the validation rules that apply to the request.
24
     *
25
     * @return array
0 ignored issues
show
introduced by
@return annotation of method \App\Http\Requests\UpdateManager::rules() does not specify type hint for items of its traversable return value.
Loading history...
26
     */
27
    public function rules()
0 ignored issues
show
introduced by
Method \App\Http\Requests\UpdateManager::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...
28
    {
29
        $frequencyRule = new ValidIdRule(Frequency::class);
30
        return [
31
            'department_id' => ['nullable', new ValidIdRule(Department::class)],
32
            /*
33
             * Twitters Terms of Service only allows ". A username can only contain
34
             * alphanumeric characters (letters A-Z, numbers 0-9) with the exception
35
             * of underscores"
36
             * This regex will allow only alphamumeric characters and the underscore.
37
             * Keep this handy if we need to validate other usernames.
38
             */
39
            'twitter_username' => [
40
                'nullable', //Some people may not have a handle.
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// Some people may not have a handle." but found "//Some people may not have a handle."
Loading history...
41
                'max:15', //Per Twitter's Terms/Service.
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// Per Twitter's Terms/Service." but found "//Per Twitter's Terms/Service."
Loading history...
42
                'regex:/^[A-Za-z0-9_]+$/',
43
            ],
44
            'linkedin_url' => [
45
                'nullable', // Some people may not be on LinkedIn
46
                'regex:/^(https:\\/\\/|http:\\/\\/)?www\\.linkedin\\.com\\/in\\/[^\\/]+(\\/)?$/', // Validation for linkedIn profile URLS only.
47
            ],
48
            'work_review_frequency_id' => ['nullable', $frequencyRule],
49
            'stay_late_frequency_id' => ['nullable', $frequencyRule],
50
            'engage_team_frequency_id' => ['nullable', $frequencyRule],
51
            'development_opportunity_frequency_id' => ['nullable', $frequencyRule],
52
            'refuse_low_value_work_frequency_id' => ['nullable', $frequencyRule],
53
            'years_experience' => 'nullable|numeric',
54
55
            'en.about_me' => 'nullable|string',
56
            'en.greatest_accomplishment' => 'nullable|string',
57
            'en.branch' => 'nullable|string',
58
            'en.division' => 'nullable|string',
59
            'en.position' => 'nullable|string',
60
            'en.leadership_style' => 'nullable|string',
61
            'en.employee_learning' => 'nullable|string',
62
            'en.expectations' => 'nullable|string',
63
            'en.education' => 'nullable|string',
64
            'en.career_journey' => 'nullable|string',
65
            'en.learning_path' => 'nullable|string',
66
67
            'fr.about_me' => 'nullable|string',
68
            'fr.greatest_accomplishment' => 'nullable|string',
69
            'fr.branch' => 'nullable|string',
70
            'fr.division' => 'nullable|string',
71
            'fr.position' => 'nullable|string',
72
            'fr.leadership_style' => 'nullable|string',
73
            'fr.employee_learning' => 'nullable|string',
74
            'fr.expectations' => 'nullable|string',
75
            'fr.education' => 'nullable|string',
76
            'fr.career_journey' => 'nullable|string',
77
            'fr.learning_path' => 'nullable|string',
78
        ];
79
    }
80
}
81