Completed
Pull Request — master (#60)
by ARCANEDEV
05:11 queued 03:57
created

CaptchaRule::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\NoCaptcha\Rules;
2
3
use Arcanedev\NoCaptcha\Contracts\NoCaptcha;
4
use Illuminate\Contracts\Validation\Rule;
5
6
/**
7
 * Class     CaptchaRule
8
 *
9
 * @package  Arcanedev\NoCaptcha\Rules
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class CaptchaRule implements Rule
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main methods
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Determine if the validation rule passes.
21
     *
22
     * @param  string  $attribute
23
     * @param  mixed   $value
24
     *
25
     * @return bool
26
     */
27 4
    public function passes($attribute, $value)
28
    {
29 4
        return app(NoCaptcha::class)->verify($value, request()->ip());
30
    }
31
32
    /**
33
     * Get the validation error message.
34
     *
35
     * @return string
36
     */
37 2
    public function message()
38
    {
39 2
        return trans('validation.captcha');
40
    }
41
}
42