| Conditions | 7 |
| Paths | 20 |
| Total Lines | 104 |
| Code Lines | 72 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| 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 |
||
| 135 | public function update(Request $request, Manager $manager) { |
||
| 136 | $input = $request->input(); |
||
| 137 | |||
| 138 | //TODO: remove control of name in production |
||
| 139 | $manager->user->name = $input['name']; |
||
| 140 | $manager->user->save(); |
||
| 141 | |||
| 142 | $manager->fill([ |
||
| 143 | 'department_id' => $input['department'], |
||
| 144 | 'twitter_username' => $input['twitter_username'], |
||
| 145 | 'linkedin_url' => $input['linkedin_url'], |
||
| 146 | //'work_review_frequency_id' => [], |
||
| 147 | //'stay_late_frequency_id' => [], |
||
| 148 | //'engage_team_frequency_id' => [], |
||
| 149 | //'development_opportunity_frequency_id', |
||
| 150 | //'refuse_low_value_work_frequency_id', |
||
| 151 | 'years_experience' => $input['years_experience'], |
||
| 152 | 'en' => [ |
||
| 153 | 'about_me' => $input['about_me']['en'], |
||
| 154 | //'greatest_accomplishment', |
||
| 155 | 'branch' => $input['branch']['en'], |
||
| 156 | 'division' => $input['division']['en'], |
||
| 157 | 'position' => $input['position']['en'], |
||
| 158 | 'leadership_style' => $input['leadership_style']['en'], |
||
| 159 | 'employee_learning' => $input['employee_learning']['en'], |
||
| 160 | 'expectations' => $input['expectations']['en'], |
||
| 161 | 'education' => $input['education']['en'], |
||
| 162 | 'career_journey' => $input['career_journey']['en'], |
||
| 163 | 'learning_path' => $input['learning_path']['en'] |
||
| 164 | ], |
||
| 165 | 'fr' => [ |
||
| 166 | 'about_me' => $input['about_me']['fr'], |
||
| 167 | //'greatest_accomplishment', |
||
| 168 | 'branch' => $input['branch']['fr'], |
||
| 169 | 'division' => $input['division']['fr'], |
||
| 170 | 'position' => $input['position']['fr'], |
||
| 171 | 'leadership_style' => $input['leadership_style']['fr'], |
||
| 172 | 'employee_learning' => $input['employee_learning']['fr'], |
||
| 173 | 'expectations' => $input['expectations']['fr'], |
||
| 174 | 'education' => $input['education']['fr'], |
||
| 175 | 'career_journey' => $input['career_journey']['fr'], |
||
| 176 | 'learning_path' => $input['learning_path']['fr'] |
||
| 177 | ] |
||
| 178 | ]); |
||
| 179 | |||
| 180 | $manager->save(); |
||
| 181 | |||
| 182 | $work_environment = $manager->work_environment; |
||
| 183 | $work_environment->fill([ |
||
| 184 | 'en' => [ |
||
| 185 | 'things_to_know' => $input['things_to_know']['en'] |
||
| 186 | ], |
||
| 187 | 'fr' => [ |
||
| 188 | 'things_to_know' => $input['things_to_know']['fr'] |
||
| 189 | ] |
||
| 190 | ]); |
||
| 191 | //Slider select inputs can be missing from input if nothing was selected |
||
| 192 | if (isset($input['telework'])) { |
||
| 193 | $work_environment->telework_allowed_frequency_id = $input['telework']; |
||
| 194 | } |
||
| 195 | if (isset($input['flex_hours'])) { |
||
| 196 | $work_environment->flexible_hours_frequency_id = $input['flex_hours']; |
||
| 197 | } |
||
| 198 | $work_environment->save(); |
||
| 199 | |||
| 200 | $team_culture = $manager->team_culture; |
||
| 201 | $team_culture->fill([ |
||
| 202 | 'team_size' => $input['team_size'], |
||
| 203 | 'gc_directory_url' => $input['gc_directory_url'], |
||
| 204 | 'en' => [ |
||
| 205 | 'operating_context' => $input['operating_context']['en'], |
||
| 206 | 'what_we_value' => $input['what_we_value']['en'], |
||
| 207 | 'how_we_work' => $input['how_we_work']['en'] |
||
| 208 | ], |
||
| 209 | 'fr' => [ |
||
| 210 | 'operating_context' => $input['operating_context']['fr'], |
||
| 211 | 'what_we_value' => $input['what_we_value']['fr'], |
||
| 212 | 'how_we_work' => $input['how_we_work']['fr'] |
||
| 213 | ] |
||
| 214 | ]); |
||
| 215 | $team_culture->save(); |
||
| 216 | |||
| 217 | //TODO: save workplace Photos |
||
| 218 | |||
| 219 | //Use the button that was clicked to decide which element to redirect to |
||
| 220 | switch ($input['submit']) { |
||
| 221 | case 'about_me': |
||
| 222 | $hash = '#managerProfileSectionAbout'; |
||
| 223 | break; |
||
| 224 | case 'team_culture': |
||
| 225 | $hash = '#managerProfileSectionCulture'; |
||
| 226 | break; |
||
| 227 | case 'work_environment': |
||
| 228 | $hash = '#managerProfileSectionEnvrionment'; |
||
| 229 | break; |
||
| 230 | case 'leadership': |
||
| 231 | $hash = '#managerProfileSectionLeadership'; |
||
| 232 | break; |
||
| 233 | default: |
||
| 234 | $hash = ""; |
||
| 235 | break; |
||
| 236 | } |
||
| 237 | |||
| 238 | return redirect( route('manager.profile.edit', $manager).$hash ); |
||
|
1 ignored issue
–
show
|
|||
| 239 | } |
||
| 242 |