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 |
||
53 | public function create(Request $request) |
||
54 | { |
||
55 | // Check if an old player |
||
56 | $player = NULL; |
||
57 | if ($request->has('facebook_id') && !empty($request->facebook_id)) { |
||
58 | $player = Player::findByFacebookId($request->facebook_id); |
||
59 | } else if ($request->has('playgames_id') && !empty($request->playgames_id)) { |
||
60 | $player = Player::findByPlayGamesId($request->playgames_id); |
||
61 | } else if ($request->has('gamecenter_id') && !empty($request->gamecenter_id)) { |
||
62 | $player = Player::findByGameCenterId($request->gamecenter_id); |
||
63 | } else if ($request->has('udid') && !empty($request->udid)) { |
||
64 | $player = Player::findByUdid($request->udid); |
||
65 | } |
||
66 | |||
67 | // Create or update |
||
68 | $data = $request->all(); |
||
69 | $data['ip'] = filter_input(INPUT_SERVER, "REMOTE_ADDR"); |
||
70 | if ($player) { |
||
71 | $player->update($data); |
||
72 | } else { |
||
73 | $player = Player::create($data); |
||
74 | } |
||
75 | |||
76 | // Update/create GamePlayer entry if not exists |
||
77 | if ($request->has('game_id')) { |
||
78 | $playerGame = GamePlayer::findByGamePlayer($request->game_id, $player->id); |
||
79 | if ($playerGame) { |
||
80 | $playerGame->update($request->all()); |
||
81 | } else { |
||
82 | $data = $request->all(); |
||
83 | $data['player_id'] = $player->id; |
||
84 | GamePlayer::create($data); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | return response($player, 200); |
||
89 | } |
||
144 | } |
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