Passed
Push — feature/job-env-culture ( 7a7dee...bc1cda )
by Tristan
09:29
created

UpdateJobPoster   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 34
dl 0
loc 52
ccs 34
cts 34
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 33 1
A authorize() 0 5 2
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Support\Facades\Config;
7
use App\Services\Validation\Rules\ValidIdRule;
8
use App\Models\Lookup\Department;
9
use App\Models\Lookup\Province;
10
use App\Models\Lookup\SecurityClearance;
11
use App\Models\Lookup\LanguageRequirement;
12
use App\Models\JobPoster;
13
14
class UpdateJobPoster extends FormRequest
15
{
16
    /**
17
     * Determine if the user is authorized to make this request.
18
     *
19
     * @return boolean
20
     */
21 3
    public function authorize(): bool
22
    {
23 3
        $job = $this->route('job');
24
        // Published jobs cannot be updated.
25 3
        return $job && $job->published_at === null;
26
    }
27
28
    /**
29
     * Get the validation rules that apply to the request.
30
     *
31
     * @return string[]
32
     */
33 4
    public function rules(): array
34
    {
35 4
        $dateFormat = Config::get('app.api_datetime_format');
36 4
        $dateFormatRule = "date_format:$dateFormat";
37
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('term_qty' ...' => 'nullable|string') returns an array which contains values of type array<integer,App\Servic...>|array<integer,string> which are incompatible with the documented value type string.
Loading history...
38 4
            'term_qty' => 'nullable|numeric',
39 4
            'open_date_time' =>['nullable', $dateFormatRule],
40 4
            'close_date_time' => ['nullable', $dateFormatRule],
41 4
            'start_date_time' =>['nullable', $dateFormatRule],
42 4
            'department_id' => ['nullable', new ValidIdRule(Department::class)],
43 4
            'province_id' => ['nullable', new ValidIdRule(Province::class)],
44 4
            'security_clearance_id' => ['nullable', new ValidIdRule(SecurityClearance::class)],
45 4
            'language_requirement_id' => ['nullable', new ValidIdRule(LanguageRequirement::class)],
46 4
            'salary_min' => 'nullable|numeric',
47 4
            'salary_max' => 'nullable|numeric',
48 4
            'noc' => 'nullable|numeric',
49 4
            'classification_code' => 'nullable|regex:/[A-Z]{2}/',
50 4
            'classification_level' => 'nullable|numeric',
51 4
            'remote_work_allowed' => 'nullable|boolean',
52 4
            'en.city' => 'nullable|string',
53 4
            'en.title' => 'nullable|string',
54 4
            'en.team_impact' => 'nullable|string',
55 4
            'en.hire_impact' => 'nullable|string',
56 4
            'en.division' => 'nullable|string',
57 4
            'en.branch' => 'nullable|string',
58 4
            'en.education' => 'nullable|string',
59 4
            'fr.city' => 'nullable|string',
60 4
            'fr.title' => 'nullable|string',
61 4
            'fr.team_impact' => 'nullable|string',
62 4
            'fr.hire_impact' => 'nullable|string',
63 4
            'fr.division' => 'nullable|string',
64 4
            'fr.branch' => 'nullable|string',
65 4
            'fr.education' => 'nullable|string',
66
        ];
67
    }
68
}
69