MatchOldPassword   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A message() 0 3 1
A passes() 0 3 1
A __construct() 0 2 1
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