Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 | $frequencyRule = new ValidIdRule(Frequency::class); |
||
52 | return [ |
||
53 | '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 | 'telework_allowed_frequency_id' => ['required', $frequencyRule], |
||
84 | 'flexible_hours_frequency_id' => ['required', $frequencyRule], |
||
85 | |||
86 | 'team_size' => 'nullable|numeric|min:1', |
||
87 | 'years_experience' => 'nullable|numeric|min:0', |
||
88 | 'gc_directory_url' => 'nullable|url', |
||
89 | |||
90 | '*.about_me' => 'nullable|string', |
||
91 | '*.career_journey' => 'nullable|string', |
||
92 | '*.branch' => 'nullable|string', |
||
93 | '*.division' => 'nullable|string', |
||
94 | '*.education' => 'nullable|string', |
||
95 | '*.employee_learning' => 'nullable|string', |
||
96 | '*.expectations' => 'nullable|string', |
||
97 | '*.greatest_accomplishment' => 'nullable|string', |
||
98 | '*.how_we_work' => 'nullable|string', |
||
99 | '*.leadership_style' => 'nullable|string', |
||
100 | '*.learning_path' => 'nullable|string', |
||
101 | '*.operating_context' => 'nullable|string', |
||
102 | '*.position' => 'nullable|string', |
||
103 | '*.things_to_know' => 'nullable|string', |
||
104 | '*.what_we_value' => 'nullable|string', |
||
105 | |||
106 | 'twitter_username' => [ |
||
107 | 'nullable', // Some people may not have a handle. |
||
108 | new TwitterHandleRule, |
||
109 | ], |
||
110 | 'linkedin_url' => [ |
||
111 | 'nullable', // Some people may not be on LinkedIn. |
||
112 | new LinkedInUrlRule, |
||
113 | ], |
||
117 |