Completed
Pull Request — master (#18)
by
unknown
11:43
created

Hash::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\ValidationRules\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Illuminate\Support\Facades\Hash as HashFacade;
7
8
final class Hash implements Rule
9
{
10
    private $hash;
11
12
    public function __construct(string $hash)
13
    {
14
        $this->hash = $hash;
15
    }
16
17
    /**
18
     * Determine if the validation rule passes.
19
     *
20
     * @param  string  $attribute
21
     * @param  mixed  $plaintext
22
     * @return bool
23
     */
24
    public function passes($attribute, $plaintext)
25
    {
26
        return HashFacade::check($plaintext, $this->hash);
27
    }
28
29
    /**
30
     * Get the validation error message.
31
     *
32
     * @return string
33
     */
34
    public function message()
35
    {
36
        return __('validationRules.hash');
37
    }
38
}
39