CurrentPasswordCheckRule::passes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Illuminate\Support\Facades\Hash;
7
8
class CurrentPasswordCheckRule implements Rule
9
{
10
    /**
11
     * Determine if the validation rule passes.
12
     *
13
     * @param string $attribute
14
     * @param mixed  $value
15
     *
16
     * @return bool
17
     */
18
    public function passes($attribute, $value)
19
    {
20
        return Hash::check($value, auth()->user()->password);
21
    }
22
23
    /**
24
     * Get the validation error message.
25
     *
26
     * @return string
27
     */
28
    public function message()
29
    {
30
        return __('The current password field does not match your password');
0 ignored issues
show
Bug Best Practice introduced by
The expression return __('The current p...t match your password') also could return the type array which is incompatible with the documented return type string.
Loading history...
31
    }
32
}
33