| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 49 | public function rules() |
||
| 50 | { |
||
| 51 | return [ |
||
| 52 | 'first_name' => 'required|string|max:191', |
||
| 53 | 'last_name' => 'required|string|max:191', |
||
| 54 | 'email' => [ |
||
| 55 | 'required', |
||
| 56 | 'string', |
||
| 57 | 'max:191', |
||
| 58 | 'email', |
||
| 59 | // Email may match existing email for this user, |
||
| 60 | // but must be unique if changed. |
||
| 61 | Rule::unique('users', 'email')->ignore($this->manager->user->id) |
||
| 62 | ], |
||
| 63 | 'gov_email' => [ |
||
| 64 | 'nullable', |
||
| 65 | 'string', |
||
| 66 | 'max:191', |
||
| 67 | 'email', |
||
| 68 | ], |
||
| 69 | // Password validation |
||
| 70 | 'current_password' => [ |
||
| 71 | 'nullable', |
||
| 72 | 'required_with:new_password', |
||
| 73 | new PasswordCorrectRule |
||
| 74 | ], |
||
| 75 | 'new_password' => [ |
||
| 76 | 'nullable', |
||
| 77 | 'min:8', |
||
| 78 | new PasswordFormatRule, |
||
| 79 | 'confirmed' |
||
| 80 | ], |
||
| 81 | |||
| 82 | 'department_id' => ['required', new ValidIdRule(Department::class)], |
||
| 83 | |||
| 84 | 'years_experience' => 'nullable|numeric|min:0', |
||
| 85 | 'gc_directory_url' => 'nullable|url', |
||
| 86 | |||
| 87 | '*.about_me' => 'nullable|string', |
||
| 88 | '*.career_journey' => 'nullable|string', |
||
| 89 | '*.division' => 'nullable|string', |
||
| 90 | '*.education' => 'nullable|string', |
||
| 91 | '*.employee_learning' => 'nullable|string', |
||
| 92 | '*.expectations' => 'nullable|string', |
||
| 93 | '*.greatest_accomplishment' => 'nullable|string', |
||
| 94 | '*.leadership_style' => 'nullable|string', |
||
| 95 | '*.learning_path' => 'nullable|string', |
||
| 96 | '*.position' => 'nullable|string', |
||
| 97 | |||
| 98 | 'twitter_username' => [ |
||
| 99 | 'nullable', // Some people may not have a handle. |
||
| 100 | new TwitterHandleRule, |
||
| 101 | ], |
||
| 102 | 'linkedin_url' => [ |
||
| 103 | 'nullable', // Some people may not be on LinkedIn. |
||
| 104 | new LinkedInUrlRule, |
||
| 105 | ], |
||
| 109 |