We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
15 | class AuthenticateController extends Controller |
||
16 | { |
||
17 | /** |
||
18 | * Authenticate the user |
||
19 | * |
||
20 | * @param Request $request |
||
21 | * @return void |
||
22 | */ |
||
23 | public function authenticate(Request $request) |
||
24 | { |
||
25 | // grab credentials from the request |
||
26 | $credentials = $request->only('email', 'password'); |
||
27 | |||
28 | try { |
||
29 | // attempt to verify the credentials and create a token for the user |
||
30 | if (!$token = JWTAuth::attempt($credentials)) { |
||
31 | return response()->json([ 'error' => 'invalid_credentials' ], 401); |
||
32 | } |
||
33 | } catch (JWTException $e) { |
||
34 | // something went wrong whilst attempting to encode the token |
||
35 | return response()->json([ 'error' => 'could_not_create_token' ], 500); |
||
36 | } |
||
37 | |||
38 | // all good so return the token |
||
39 | return response()->json( |
||
40 | [ |
||
41 | 'access_token' => $token, |
||
42 | 'token_type' => 'Bearer' |
||
43 | ], 200 |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | // Register a new user |
||
48 | public function register(RegisterUserRequest $request) |
||
89 | |||
90 | /** |
||
91 | * Invalidate and log out the user |
||
92 | * |
||
93 | * @return void |
||
94 | * |
||
95 | */ |
||
96 | public function logout() |
||
100 | /** |
||
101 | * Get the current user (logged in) information |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | View Code Duplication | public function userInfo() |
|
123 | } |
||
124 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.