We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function recover(Request $request) |
||
| 19 | { |
||
| 20 | $user = User::where('email', $request->email)->first(); |
||
| 21 | if (!$user) { |
||
| 22 | $error_message = "Your email address was not found."; |
||
| 23 | return response()->json([ 'success' => false, 'error' => [ 'email' => $error_message ] ], 401); |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | try { |
||
| 27 | Password::sendResetLink($request->only('email'), function(Message $message) { |
||
| 28 | $message->subject('Your Password Reset Link'); |
||
| 29 | }); |
||
| 30 | } catch (Exception $e) { |
||
| 31 | // Return with error |
||
| 32 | $error_message = $e->getMessage(); |
||
| 33 | return response()->json([ 'success' => false, 'error' => $error_message ], 401); |
||
| 34 | } |
||
| 35 | |||
| 36 | return response()->json([ |
||
| 37 | 'success' => true, |
||
| 38 | 'data' => [ 'message' => 'A reset email has been sent! Please check your email.' ] |
||
| 39 | ]); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |
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: