| Conditions | 12 |
| Paths | 30 |
| Total Lines | 36 |
| Code Lines | 24 |
| 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 |
||
| 42 | public function create(Request $request) |
||
| 43 | { |
||
| 44 | // Check if an old player |
||
| 45 | $player = NULL; |
||
| 46 | if ($request->has('facebook_id') && !empty($request->facebook_id)) { |
||
| 47 | $player = Player::findByFacebookId($request->facebook_id); |
||
| 48 | } else if ($request->has('playgames_id') && !empty($request->playgames_id)) { |
||
| 49 | $player = Player::findByPlayGamesId($request->playgames_id); |
||
| 50 | } else if ($request->has('gamecenter_id') && !empty($request->gamecenter_id)) { |
||
| 51 | $player = Player::findByGameCenterId($request->gamecenter_id); |
||
| 52 | } else if ($request->has('udid') && !empty($request->udid)) { |
||
| 53 | $player = Player::findByUdid($request->udid); |
||
| 54 | } |
||
| 55 | |||
| 56 | // Create or update |
||
| 57 | $data = $request->all(); |
||
| 58 | $data['ip'] = filter_input(INPUT_SERVER, "REMOTE_ADDR"); |
||
| 59 | if ($player) { |
||
| 60 | $player->update($data); |
||
| 61 | } else { |
||
| 62 | $player = Player::create($data); |
||
| 63 | } |
||
| 64 | |||
| 65 | // Create playerGame if not exists |
||
| 66 | if ($request->has('game_id')) { |
||
| 67 | $playerGame = PlayerGame::findByPlayerGame($player->id, $request->game_id); |
||
| 68 | if ($playerGame) { |
||
| 69 | $playerGame->update($request->all()); |
||
| 70 | } else { |
||
| 71 | $data = $request->all(); |
||
| 72 | $data['player_id'] = $player->id; |
||
| 73 | PlayerGame::create($data); |
||
| 74 | } |
||
| 75 | } |
||
| 76 | |||
| 77 | return response($player, 200); |
||
| 78 | } |
||
| 94 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths