1 | <?php |
||
19 | class CreditCard extends Rule |
||
20 | { |
||
21 | /** |
||
22 | * A constant that will be used when the value is not a valid credit card number. |
||
23 | */ |
||
24 | const INVALID_FORMAT = 'CreditCard::INVALID_FORMAT'; |
||
25 | const INVALID_CHECKSUM = 'CreditCard::INVALID_CHECKSUM'; |
||
26 | |||
27 | /** |
||
28 | * The message templates which can be returned by this validator. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $messageTemplates = [ |
||
33 | self::INVALID_FORMAT => '{{ name }} must have a valid credit card number format', |
||
34 | self::INVALID_CHECKSUM => '{{ name }} must be a valid credit card number', |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Validates if the value is a valid credit card number. |
||
39 | * |
||
40 | * @param mixed $value |
||
41 | * @return bool |
||
42 | */ |
||
43 | 15 | public function validate($value) |
|
53 | |||
54 | /** |
||
55 | * @param $value |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 12 | private function validateChecksum($value) |
|
65 | |||
66 | /** |
||
67 | * @param $value |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | 15 | private function validateFormat($value) |
|
89 | } |
||
90 |