PasswordResetLinkController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A store() 0 19 2
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\Password;
9
use Illuminate\Validation\ValidationException;
10
use Inertia\Inertia;
11
use Inertia\Response;
12
13
class PasswordResetLinkController extends Controller
14
{
15
    /**
16
     * Display the password reset link request view.
17
     */
18
    public function create(): Response
19
    {
20
        return Inertia::render('Auth/ForgotPassword', [
21
            'status' => session('status'),
22
        ]);
23
    }
24
25
    /**
26
     * Handle an incoming password reset link request.
27
     *
28
     * @throws \Illuminate\Validation\ValidationException
29
     */
30
    public function store(Request $request): RedirectResponse
31
    {
32
        $request->validate([
0 ignored issues
show
Bug introduced by
The method validate() does not exist on Illuminate\Http\Request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $request->/** @scrutinizer ignore-call */ 
33
                  validate([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
            'email' => 'required|email',
34
        ]);
35
36
        // We will send the password reset link to this user. Once we have attempted
37
        // to send the link, we will examine the response then see the message we
38
        // need to show to the user. Finally, we'll send out a proper response.
39
        $status = Password::sendResetLink(
40
            $request->only('email')
0 ignored issues
show
Bug introduced by
The method only() does not exist on Illuminate\Http\Request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            $request->/** @scrutinizer ignore-call */ 
41
                      only('email')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        );
42
43
        if ($status == Password::RESET_LINK_SENT) {
44
            return back()->with('status', __($status));
45
        }
46
47
        throw ValidationException::withMessages([
48
            'email' => [trans($status)],
49
        ]);
50
    }
51
}
52