GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ResetPasswordController::resetPassword()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 7
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 14
ccs 0
cts 8
cp 0
crap 6
rs 10
1
<?php
2
3
namespace App\Api\V1\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Support\Facades\Password;
7
use App\Api\V1\Requests\ResetPasswordRequest;
8
use Symfony\Component\HttpKernel\Exception\HttpException;
9
10
class ResetPasswordController extends Controller
11
{
12
    public function resetPassword(ResetPasswordRequest $request)
13
    {
14
        $response = $this->broker()->reset(
15
            $this->credentials($request), function ($user, $password) {
16
                $this->reset($user, $password);
17
            }
18
        );
19
20
        if (Password::PASSWORD_RESET !== $response) {
21
            throw new HttpException(500);
22
        }
23
24
        return response()->json([
25
            'status' => 'ok',
26
        ]);
27
    }
28
29
    /**
30
     * Get the broker to be used during password reset.
31
     *
32
     * @return \Illuminate\Contracts\Auth\PasswordBroker
33
     */
34
    public function broker()
35
    {
36
        return Password::broker();
37
    }
38
39
    /**
40
     * Get the password reset credentials from the request.
41
     *
42
     * @param ResetPasswordRequest $request
43
     *
44
     * @return array
45
     */
46
    protected function credentials(ResetPasswordRequest $request)
47
    {
48
        return $request->only(
49
            'email', 'password', 'password_confirmation', 'token'
50
        );
51
    }
52
53
    /**
54
     * Reset the given user's password.
55
     *
56
     * @param \Illuminate\Contracts\Auth\CanResetPassword $user
57
     * @param string                                      $password
58
     */
59
    protected function reset($user, $password)
60
    {
61
        $user->password = $password;
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\CanResetPassword suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
62
        $user->save();
63
    }
64
}
65