Passed
Push — feature/manager_api_routes ( 47ca0c )
by Tristan
10:22
created

UpdateManager::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
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\DepartmentRule;
7
use App\Services\Validation\Rules\FrequencyRule;
8
9
class UpdateManager 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\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...
17
    {
18
        return true;
19
    }
20
21
    /**
22
     * Get the validation rules that apply to the request.
23
     *
24
     * @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...
25
     */
26
    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...
27
    {
28
        $frequencyRule = new FrequencyRule();
29
        return [
30
            'department_id' => ['nullable', new DepartmentRule()],
31
            /*
32
             * Twitters Terms of Service only allows ". A username can only contain
33
             * alphanumeric characters (letters A-Z, numbers 0-9) with the exception
34
             * of underscores"
35
             * This regex will allow only alphamumeric characters and the underscore.
36
             * Keep this handy if we need to validate other usernames.
37
             */
38
            'twitter_username' => [
39
                'nullable', //Some people may not have a handle.
40
                'max:15', //Per Twitter's Terms/Service.
41
                'regex:/^[A-Za-z0-9_]+$/',
42
            ],
43
            'linkedin_url' => [
44
                'nullable', // Some people may not be on LinkedIn
45
                'regex:/^(https:\\/\\/|http:\\/\\/)?www\\.linkedin\\.com\\/in\\/[^\\/]+(\\/)?$/', // Validation for linkedIn profile URLS only.
46
            ],
47
            'work_review_frequency_id' => ['nullable', $frequencyRule],
48
            'stay_late_frequency_id' => ['nullable', $frequencyRule],
49
            'engage_team_frequency_id' => ['nullable', $frequencyRule],
50
            'development_opportunity_frequency_id' => ['nullable', $frequencyRule],
51
            'refuse_low_value_work_frequency_id' => ['nullable', $frequencyRule],
52
            'years_experience' => 'nullable|numeric',
53
54
            'en.about_me' => 'nullable|string',
55
            'en.greatest_accomplishment' => 'nullable|string',
56
            'en.branch' => 'nullable|string',
57
            'en.division' => 'nullable|string',
58
            'en.position' => 'nullable|string',
59
            'en.work_experience' => 'nullable|string',
60
            'en.education' => 'nullable|string',
61
            'en.leadership_style' => 'nullable|string',
62
            'en.employee_learning' => 'nullable|string',
63
            'en.expectations' => 'nullable|string',
64
            'en.education' => 'nullable|string',
65
            'en.career_journey' => 'nullable|string',
66
            'en.learning_path' => 'nullable|string',
67
68
            'fr.about_me' => 'nullable|string',
69
            'fr.greatest_accomplishment' => 'nullable|string',
70
            'fr.branch' => 'nullable|string',
71
            'fr.division' => 'nullable|string',
72
            'fr.position' => 'nullable|string',
73
            'fr.work_experience' => 'nullable|string',
74
            'fr.education' => 'nullable|string',
75
            'fr.leadership_style' => 'nullable|string',
76
            'fr.employee_learning' => 'nullable|string',
77
            'fr.expectations' => 'nullable|string',
78
            'fr.education' => 'nullable|string',
79
            'fr.career_journey' => 'nullable|string',
80
            'fr.learning_path' => 'nullable|string',
81
        ];
82
    }
83
}
84