We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 79 |
| Lines | 24 |
| Ratio | 30.38 % |
| 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 |
||
| 114 | protected function userRoutes() |
||
| 115 | { |
||
| 116 | // Donors |
||
| 117 | $this->router->group( |
||
| 118 | ['namespace' => '\GiveBlood\Support\Http\Controllers', 'prefix' => 'donors'], function ($donor) { |
||
| 119 | // Because all donor is a user |
||
| 120 | // We will use UsersController instead |
||
| 121 | // All donors |
||
| 122 | $donor->get('/', 'UsersController@index'); |
||
| 123 | // show info about donor |
||
| 124 | $donor->get('{donor}', 'UsersController@show'); |
||
| 125 | |||
| 126 | // Campaigns by donor |
||
| 127 | $donor->get('{donor}/campaigns', 'UsersController@getCampaigns'); |
||
| 128 | $donor->get('{donor}/campaigns/{campaign}', 'UsersController@showCampaign'); |
||
| 129 | } |
||
| 130 | ); |
||
| 131 | // Donors API |
||
| 132 | $this->router->group( |
||
| 133 | ['namespace' => '\GiveBlood\Support\Http\Controllers', 'prefix' => 'v1'], function () { |
||
| 134 | |||
| 135 | // Routes related to logged in user |
||
| 136 | $this->router->group( |
||
| 137 | View Code Duplication | ['prefix' => 'me', 'namespace' => 'User'], function ($user) { |
|
| 138 | // Get user information. |
||
| 139 | $user->get('/', 'AccountController@userInfo'); |
||
| 140 | // Update User profile information. |
||
| 141 | $user->put('/', 'AccountController@updateProfile'); |
||
| 142 | // User campigns |
||
| 143 | $user->group( |
||
| 144 | ['prefix' => 'campaigns'], function ($campaign) { |
||
| 145 | // Get all user Campaigns. |
||
| 146 | $campaign->get('/', 'CampaignController@index'); |
||
| 147 | // Create Campaign |
||
| 148 | $campaign->post('/', 'CampaignController@store'); |
||
| 149 | // Show complete info about campaign |
||
| 150 | $campaign->get('/{campaign}', 'CampaignController@show'); |
||
| 151 | // Update campaign |
||
| 152 | $campaign->put('/{campaign}', 'CampaignController@update'); |
||
| 153 | // Detele Campaign |
||
| 154 | $campaign->delete('/{campaign}', 'CampaignController@destroy'); |
||
| 155 | } |
||
| 156 | ); |
||
| 157 | |||
| 158 | // User donations |
||
| 159 | $user->get('/donations', 'DonationController@donations'); |
||
| 160 | } |
||
| 161 | ); |
||
| 162 | |||
| 163 | // Blood Banks |
||
| 164 | $this->router->group( |
||
| 165 | ['prefix' => 'banks'], function ($bank) { |
||
| 166 | $bank->get('/', 'BankController@index'); |
||
| 167 | $bank->get('/{bank}', 'BankController@show'); |
||
| 168 | } |
||
| 169 | ); |
||
| 170 | |||
| 171 | // BloodTypes |
||
| 172 | $this->router->group( |
||
| 173 | ['prefix' => 'bloodtypes'], function () { |
||
| 174 | $this->router->get('/', 'BloodTypeController@index'); |
||
| 175 | } |
||
| 176 | ); |
||
| 177 | /* |
||
| 178 | // Invites. |
||
| 179 | Route::group( |
||
| 180 | ['prefix' => 'invites'], function ($invite) { |
||
| 181 | // Create a new invite. |
||
| 182 | $invite->post('/', 'InvitesController@create'); |
||
| 183 | // Get a Invite details. |
||
| 184 | $invite->get('/{invite}', 'InvitesController@show'); |
||
| 185 | // Delete a invite. |
||
| 186 | $invite->delete('/{invite}', 'InvitesController@destroy'); |
||
| 187 | } |
||
| 188 | ); |
||
| 189 | */ |
||
| 190 | } |
||
| 191 | ); |
||
| 192 | } |
||
| 193 | |||
| 219 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: