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

CaptchaRule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 30
ccs 4
cts 4
cp 1
rs 10

2 Methods

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