Completed
Pull Request — master (#17)
by Fèvre
05:35 queued 02:55
created

ResetPasswordController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 59
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sendResetResponse() 0 5 1
A __construct() 0 4 1
A showResetForm() 0 6 1
1
<?php
2
namespace Xetaravel\Http\Controllers\Auth;
3
4
use Illuminate\Foundation\Auth\ResetsPasswords;
5
use Illuminate\Http\Request;
6
use Xetaravel\Http\Controllers\Controller;
7
8
class ResetPasswordController extends Controller
9
{
10
    /*
11
    |--------------------------------------------------------------------------
12
    | Password Reset Controller
13
    |--------------------------------------------------------------------------
14
    |
15
    | This controller is responsible for handling password reset requests
16
    | and uses a simple trait to include this behavior. You're free to
17
    | explore this trait and override any methods you wish to tweak.
18
    |
19
    */
20
    use ResetsPasswords;
21
22
    /**
23
     * Where to redirect users after resetting their password.
24
     *
25
     * @var string
26
     */
27
    protected $redirectTo = '/';
28
29
    /**
30
     * Create a new controller instance.
31
     */
32
    public function __construct()
33
    {
34
        $this->middleware('guest');
35
    }
36
37
    /**
38
     * Display the password reset view for the given token.
39
     *
40
     * If no token is present, display the link request form.
41
     *
42
     * @param  \Illuminate\Http\Request  $request
43
     * @param  string|null  $token
44
     *
45
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
46
     */
47
    public function showResetForm(Request $request, $token = null)
48
    {
49
        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...
50
            ['token' => $token, 'email' => $request->email]
51
        );
52
    }
53
54
    /**
55
     * Get the response for a successful password reset.
56
     *
57
     * @param  string  $response
58
     *
59
     * @return \Illuminate\Http\RedirectResponse
60
     */
61
    protected function sendResetResponse($response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
    {
63
        return redirect($this->redirectPath())
64
            ->with('success', 'Your password has been reset!');
65
    }
66
}
67