ResetPasswordController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A showResetForm() 0 6 1
A rules() 0 8 1
A credentials() 0 6 1
A sendResetFailedResponse() 0 6 1
1
<?php
2
3
namespace Torralbodavid\DuckFunkCore\Http\Controllers\Auth;
4
5
use Illuminate\Foundation\Auth\ResetsPasswords;
6
use Illuminate\Http\Request;
7
use Illuminate\Routing\Controller;
8
9
class ResetPasswordController extends Controller
10
{
11
    /*
12
    |--------------------------------------------------------------------------
13
    | Password Reset Controller
14
    |--------------------------------------------------------------------------
15
    |
16
    | This controller is responsible for handling password reset requests
17
    | and uses a simple trait to include this behavior. You're free to
18
    | explore this trait and override any methods you wish to tweak.
19
    |
20
    */
21
22
    use ResetsPasswords;
23
24
    /**
25
     * Where to redirect users after resetting their password.
26
     *
27
     * @var string
28
     */
29
    protected $redirectTo = '/home';
30
31
    public function showResetForm(Request $request, $token = null)
32
    {
33
        return view('auth.passwords.reset')->with(
0 ignored issues
show
Bug introduced by
The method with does only exist in Illuminate\View\View, but not in Illuminate\Contracts\View\Factory.

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:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
34
            ['token' => $token, 'mail' => $request->mail]
35
        );
36
    }
37
38
    protected function rules()
39
    {
40
        return [
41
            'token' => 'required',
42
            'mail' => 'required|email',
43
            'password' => 'required|confirmed|min:8',
44
        ];
45
    }
46
47
    protected function credentials(Request $request)
48
    {
49
        return $request->only(
50
            'mail', 'password', 'password_confirmation', 'token'
51
        );
52
    }
53
54
    protected function sendResetFailedResponse(Request $request, $response)
55
    {
56
        return redirect()->back()
57
            ->withInput($request->only('mail'))
58
            ->withErrors(['mail' => trans($response)]);
59
    }
60
}
61