Passed
Push — master ( e287ea...a2c899 )
by Adam
05:22
created

CurrentPassword::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
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\Auth;
7
use Illuminate\Support\Facades\Hash;
8
9
class CurrentPassword implements Rule
10
{
11
    /**
12
     * Determine if the validation rule passes.
13
     *
14
     * @param  string  $attribute
15
     * @param  mixed  $value
16
     * @return bool
17
     */
18
    public function passes($attribute, $value)
19
    {
20
        return Hash::check($value, Auth::user()->password);
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21
    }
22
23
    /**
24
     * Get the validation error message.
25
     *
26
     * @return string
27
     */
28
    public function message()
29
    {
30
        return trans('validation.current_password');
31
    }
32
}
33