Completed
Push — master ( 41a1c8...e65970 )
by Mohamed
03:30 queued 15s
created

ResetPasswordController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A redirectTo() 0 4 1
A showResetForm() 0 6 1
1
<?php
2
3
namespace Microboard\Http\Controllers\Auth;
4
5
use Illuminate\Http\Request;
6
use Microboard\Http\Controllers\Controller;
7
use Illuminate\Foundation\Auth\ResetsPasswords;
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 when the intended url fails.
26
     */
27
    protected function redirectTo()
28
    {
29
        return url(config('microboard.routes.prefix'));
30
    }
31
32
    /**
33
     * Display the password reset view for the given token.
34
     *
35
     * If no token is present, display the link request form.
36
     *
37
     * @param  \Illuminate\Http\Request  $request
38
     * @param  string|null  $token
39
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
40
     */
41
    public function showResetForm(Request $request, $token = null)
42
    {
43
        return view('microboard::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...
44
            ['token' => $token, 'email' => $request->email]
45
        );
46
    }
47
}
48