Passed
Push — master ( 426355...de4e88 )
by Dennis
03:38
created

BankCardRule::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
namespace SimpleCMS\Bank\Validation\Rule;
3
4
use Illuminate\Contracts\Validation\Rule;
5
use SimpleCMS\Bank\Validation\BankCard;
6
7
/**
8
 * 银行卡号
9
 *
10
 * @author Dennis Lui <[email protected]>
11
 */
12
class BankCardRule implements Rule
13
{
14
15
    /**
16
     * Determine if the validation rule passes.
17
     *
18
     * @param  string  $attribute
19
     * @param  mixed  $value
20
     * @return bool
21
     */
22
    public function passes($attribute, $value)
23
    {
24
        return (new BankCard($value))->isValid();
25
    }
26
27
    /**
28
     * Get the validation error message.
29
     *
30
     * @return string|array
31
     */
32
    public function message()
33
    {
34
        return 'The card number is incorrect.';
35
    }
36
}