We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 16 | class CreditCard extends AbstractRule |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | public $brand; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | private $brands = [ |
||
| 27 | 'American Express' => '/^3[47]\d{13}$/', |
||
| 28 | 'Diners Club' => '/^3(?:0[0-5]|[68]\d)\d{11}$/', |
||
| 29 | 'Discover' => '/^6(?:011|5\d{2})\d{12}$/', |
||
| 30 | 'JCB' => '/^(?:2131|1800|35\d{3})\d{11}$/', |
||
| 31 | 'MasterCard' => '/^5[1-5]\d{14}$/', |
||
| 32 | 'Visa' => '/^4\d{12}(?:\d{3})?$/', |
||
| 33 | ]; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $brand Optional credit card brand. |
||
| 37 | */ |
||
| 38 | 3 | public function __construct($brand = null) |
|
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | 26 | public function validate($input) |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Returns whether the input matches the Luhn algorithm or not. |
||
| 69 | * |
||
| 70 | * @param string $input |
||
| 71 | * |
||
| 72 | * @return bool |
||
| 73 | */ |
||
| 74 | 23 | private function verifyMod10($input) |
|
| 93 | |||
| 94 | /** |
||
| 95 | * Returns whether the input matches the defined credit card brand or not. |
||
| 96 | * |
||
| 97 | * @param string $input |
||
| 98 | * |
||
| 99 | * @return bool |
||
| 100 | */ |
||
| 101 | 20 | private function verifyBrand($input) |
|
| 111 | } |
||
| 112 |