Passed
Push — feature/job-builder/step-0 ( d77267 )
by Yonathan
10:26
created

UpdateManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 40
dl 0
loc 68
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A rules() 0 51 1
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 2
    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 2
        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 2
    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 2
        $frequencyRule = new FrequencyRule();
29
        return [
30 2
            '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 2
            'work_review_frequency_id' => ['nullable', $frequencyRule],
48 2
            'stay_late_frequency_id' => ['nullable', $frequencyRule],
49 2
            'engage_team_frequency_id' => ['nullable', $frequencyRule],
50 2
            'development_opportunity_frequency_id' => ['nullable', $frequencyRule],
51 2
            'refuse_low_value_work_frequency_id' => ['nullable', $frequencyRule],
52 2
            'years_experience' => 'nullable|numeric',
53
54 2
            'en.about_me' => 'nullable|string',
55 2
            'en.greatest_accomplishment' => 'nullable|string',
56 2
            'en.branch' => 'nullable|string',
57 2
            'en.division' => 'nullable|string',
58 2
            'en.position' => 'nullable|string',
59 2
            'en.leadership_style' => 'nullable|string',
60 2
            'en.employee_learning' => 'nullable|string',
61 2
            'en.expectations' => 'nullable|string',
62 2
            'en.education' => 'nullable|string',
63 2
            'en.career_journey' => 'nullable|string',
64 2
            'en.learning_path' => 'nullable|string',
65
66 2
            'fr.about_me' => 'nullable|string',
67 2
            'fr.greatest_accomplishment' => 'nullable|string',
68 2
            'fr.branch' => 'nullable|string',
69 2
            'fr.division' => 'nullable|string',
70 2
            'fr.position' => 'nullable|string',
71 2
            'fr.leadership_style' => 'nullable|string',
72 2
            'fr.employee_learning' => 'nullable|string',
73 2
            'fr.expectations' => 'nullable|string',
74 2
            'fr.education' => 'nullable|string',
75 2
            'fr.career_journey' => 'nullable|string',
76 2
            'fr.learning_path' => 'nullable|string',
77
        ];
78
    }
79
}
80