| Conditions | 10 |
| Paths | 6 |
| Total Lines | 38 |
| Code Lines | 28 |
| 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 |
||
| 97 | public function acceptInvite(Request $request, RespondInvitationToAnOrganization $respondInvitationToAnOrganization) |
||
| 98 | { |
||
| 99 | $action = $respondInvitationToAnOrganization->respond($token = $request->input('token')); |
||
| 100 | if($action['action'] == 'register'){ |
||
| 101 | $request->session()->flash('should_attach_to_organization', $action['organization_id']); |
||
| 102 | $request->session()->flash('user_to_register', $action['user']); |
||
| 103 | return redirect()->route('register'); |
||
| 104 | } |
||
| 105 | if($action['action'] == 'accept_or_decline'){ |
||
| 106 | $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id()); |
||
| 107 | return view('organizations.accept-or-decline-invitation', [ |
||
| 108 | 'old_organisation' => isset($action['old_organisation']) ? $action['old_organisation']->toArray() : null, |
||
| 109 | 'organization_to_join' => isset($action['organization_to_join']) ? $action['organization_to_join']->toArray() : null |
||
| 110 | ]); |
||
| 111 | } |
||
| 112 | if($action['action'] == 'logout-login'){ |
||
| 113 | $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id()); |
||
| 114 | $request->session()->flash('should_attach_to_organization_token', $token); |
||
| 115 | $request->session()->flash('should_attach_to_organization_redirect', route('login')); |
||
| 116 | return view('organizations.logout-to-accept-or-decline-invitation', [ |
||
| 117 | 'organization_to_join' => isset($action['organization_to_join']) ? $action['organization_to_join']->toArray() : null |
||
| 118 | ]); |
||
| 119 | } |
||
| 120 | |||
| 121 | if($action['action'] == 'login'){ |
||
| 122 | $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id()); |
||
| 123 | $request->session()->flash('should_attach_to_organization_token', $token); |
||
| 124 | $request->session()->flash('should_attach_to_organization_redirect', route('login')); |
||
| 125 | return redirect()->route('login'); |
||
| 126 | } |
||
| 127 | |||
| 128 | if($action['action'] == 'logout-register'){ |
||
| 129 | $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id()); |
||
| 130 | $request->session()->flash('should_attach_to_organization_token', $token); |
||
| 131 | $request->session()->flash('should_attach_to_organization_redirect', route('register')); |
||
| 132 | $request->session()->flash('user_to_register', $action['user']); |
||
| 133 | return view('organizations.logout-to-accept-or-decline-invitation', [ |
||
| 134 | 'organization_to_join' => isset($action['organization_to_join']) ? $action['organization_to_join']->toArray() : null |
||
| 135 | ]); |
||
| 148 |