| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 38 |
| 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 |
||
| 27 | public function rules() |
||
| 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. |
||
| 41 | 'max:15', //Per Twitter's Terms/Service. |
||
| 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 | ]; |
||
| 81 |