| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 34 | public function rules(): array |
||
| 35 | { |
||
| 36 | $dateFormat = Config::get('app.api_datetime_format'); |
||
| 37 | $dateFormatRule = "date_format:$dateFormat"; |
||
| 38 | $sliderRule = 'between:1,4'; |
||
| 39 | return [ |
||
|
|
|||
| 40 | 'term_qty' => 'nullable|numeric', |
||
| 41 | 'open_date_time' =>['nullable', $dateFormatRule], |
||
| 42 | 'close_date_time' => ['nullable', $dateFormatRule], |
||
| 43 | 'start_date_time' =>['nullable', $dateFormatRule], |
||
| 44 | 'department_id' => ['nullable', new ValidIdRule(Department::class)], |
||
| 45 | 'province_id' => ['nullable', new ValidIdRule(Province::class)], |
||
| 46 | 'security_clearance_id' => ['nullable', new ValidIdRule(SecurityClearance::class)], |
||
| 47 | 'language_requirement_id' => ['nullable', new ValidIdRule(LanguageRequirement::class)], |
||
| 48 | 'salary_min' => 'nullable|numeric', |
||
| 49 | 'salary_max' => 'nullable|numeric', |
||
| 50 | 'noc' => 'nullable|numeric', |
||
| 51 | 'classification_code' => 'nullable|regex:/[A-Z]{2}/', |
||
| 52 | 'classification_level' => 'nullable|numeric', |
||
| 53 | 'remote_work_allowed' => 'nullable|boolean', |
||
| 54 | 'team_size' => 'nullable|numeric', |
||
| 55 | 'work_env_features' => 'nullable|array', |
||
| 56 | 'work_env_features.*' => 'boolean', // Ensure work_env_features is an array of boolean flags. |
||
| 57 | 'fast_vs_steady' => ['nullable', $sliderRule], |
||
| 58 | 'horizontal_vs_vertical' => ['nullable', $sliderRule], |
||
| 59 | 'experimental_vs_ongoing' => ['nullable', $sliderRule], |
||
| 60 | 'citizen_facing_vs_back_office' => ['nullable', $sliderRule], |
||
| 61 | 'collaborative_vs_independent' => ['nullable', $sliderRule], |
||
| 62 | 'telework_allowed_frequency_id' => ['nullable', new ValidIdRule(Frequency::class)], |
||
| 63 | 'flexible_hours_frequency_id' => ['nullable', new ValidIdRule(Frequency::class)], |
||
| 64 | 'en.city' => 'nullable|string', |
||
| 65 | 'en.title' => 'nullable|string', |
||
| 66 | 'en.dept_impact' => 'nullable|string', |
||
| 67 | 'en.team_impact' => 'nullable|string', |
||
| 68 | 'en.hire_impact' => 'nullable|string', |
||
| 69 | 'en.division' => 'nullable|string', |
||
| 70 | 'en.branch' => 'nullable|string', |
||
| 71 | 'en.education' => 'nullable|string', |
||
| 72 | 'en.work_env_description' => 'nullable|string', |
||
| 73 | 'en.culture_summary' => 'nullable|string', |
||
| 74 | 'en.culture_special' => 'nullable|string', |
||
| 75 | 'fr.city' => 'nullable|string', |
||
| 76 | 'fr.title' => 'nullable|string', |
||
| 77 | 'fr.dept_impact' => 'nullable|string', |
||
| 78 | 'fr.team_impact' => 'nullable|string', |
||
| 79 | 'fr.hire_impact' => 'nullable|string', |
||
| 80 | 'fr.division' => 'nullable|string', |
||
| 81 | 'fr.branch' => 'nullable|string', |
||
| 82 | 'fr.education' => 'nullable|string', |
||
| 83 | 'fr.work_env_description' => 'nullable|string', |
||
| 84 | 'fr.culture_summary' => 'nullable|string', |
||
| 85 | 'fr.culture_special' => 'nullable|string', |
||
| 86 | ]; |
||
| 89 |