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 | const AMERICAN_EXPRESS = 'American Express'; |
||
| 19 | const DINERS_CLUB = 'Diners Club'; |
||
| 20 | const DISCOVER = 'Discover'; |
||
| 21 | const JCB = 'JCB'; |
||
| 22 | const MASTERCARD = 'MasterCard'; |
||
| 23 | const VISA = 'Visa'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | public $brand; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | private $brands = [ |
||
| 34 | self::AMERICAN_EXPRESS => '/^3[47]\d{13}$/', |
||
| 35 | self::DINERS_CLUB => '/^3(?:0[0-5]|[68]\d)\d{11}$/', |
||
| 36 | self::DISCOVER => '/^6(?:011|5\d{2})\d{12}$/', |
||
| 37 | self::JCB => '/^(?:2131|1800|35\d{3})\d{11}$/', |
||
| 38 | self::MASTERCARD => '/(5[1-5]|2[2-7])\d{14}$/', |
||
| 39 | self::VISA => '/^4\d{12}(?:\d{3})?$/', |
||
| 40 | ]; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param string $brand Optional credit card brand |
||
| 44 | */ |
||
| 45 | public function __construct($brand = null) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | public function validate($input) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Returns whether the input matches the Luhn algorithm or not. |
||
| 76 | * |
||
| 77 | * @param string $input |
||
| 78 | * |
||
| 79 | * @return bool |
||
| 80 | */ |
||
| 81 | private function verifyMod10($input) |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Returns whether the input matches the defined credit card brand or not. |
||
| 103 | * |
||
| 104 | * @param string $input |
||
| 105 | * |
||
| 106 | * @return bool |
||
| 107 | */ |
||
| 108 | private function verifyBrand($input) |
||
| 118 | } |
||
| 119 |