We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 2 |
Paths | 2 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
16 | public function userInfo() |
||
17 | { |
||
18 | $user = JWTAuth::parseToken()->authenticate(); |
||
19 | |||
20 | // If the token is invalid |
||
21 | if (!$user) { |
||
22 | return response()->json([ 'invalid_user' ], 401); |
||
|
|||
23 | } |
||
24 | // Return the user data in json. |
||
25 | return response()->json( |
||
26 | [ |
||
27 | 'first_name' => $user->first_name, |
||
28 | 'last_name' => $user->last_name, |
||
29 | 'email' => $user->email, |
||
30 | 'username' => $user->username, |
||
31 | 'blood_type' => $user->donor->bloodType->code, |
||
32 | 'avatar' => '', //$user->avatar, |
||
33 | 'birthdate' => $user->birthdate, |
||
34 | 'phone' => $user->phone, |
||
35 | 'bio' => $user->bio |
||
36 | ], 200 |
||
37 | ); |
||
38 | |||
39 | } |
||
40 | |||
46 |
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: