MatchOldPassword::passes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Illuminate\Support\Facades\Hash;
7
8
class MatchOldPassword implements Rule
9
{
10
    /**
11
     * Create a new rule instance.
12
     *
13
     * @return void
14
     */
15
    public function __construct()
16
    {
17
        //
18
    }
19
20
    /**
21
     * Determine if the validation rule passes.
22
     *
23
     * @param  string  $attribute
24
     * @param  mixed  $value
25
     * @return bool
26
     */
27
    public function passes($attribute, $value)
28
    {
29
        return Hash::check($value, auth()->user()->password);
30
    }
31
32
    /**
33
     * Get the validation error message.
34
     *
35
     * @return string
36
     */
37
    public function message()
38
    {
39
        return 'The :attribute is match with old password.';
40
    }
41
}
42