Created
September 25, 2017 20:45
-
-
Save stephandesouza/26b898e4df2d163ed3eeac183daa8e0b to your computer and use it in GitHub Desktop.
Zend's CreditCard Validator with Elo and Hipercard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Validator; | |
use Zend\Validator\CreditCard as ZendCreditCard; | |
class CreditCard extends ZendCreditCard | |
{ | |
const HIPERCARD = 'HiperCard'; | |
const ELO = 'Elo'; | |
/** | |
* CreditCard constructor. | |
* | |
* @param array|string|\Traversable $options | |
*/ | |
public function __construct($options = []) | |
{ | |
$this->addHipercard(); | |
$this->addElo(); | |
parent::__construct($options); | |
} | |
/** | |
* Adiciona o Hipercard nas possibilidades de cartões | |
*/ | |
protected function addHipercard() | |
{ | |
$this->cardName[11] = self::HIPERCARD; | |
$this->cardLength[self::HIPERCARD] = [13, 16, 19]; | |
$this->cardType[self::HIPERCARD] = ['3841', '606282']; | |
} | |
/** | |
* Adiciona o Hipercard nas possibilidades de cartões | |
*/ | |
protected function addElo() | |
{ | |
$this->cardName[12] = self::ELO; | |
$this->cardLength[self::ELO] = [16]; | |
$this->cardType[self::ELO] = [ | |
'636368', '636369', '438935', '504175', '451416', '636297', '5067', '4576', '4011', '506699' | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment