Skip to content

Instantly share code, notes, and snippets.

@stephandesouza
Created September 25, 2017 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephandesouza/26b898e4df2d163ed3eeac183daa8e0b to your computer and use it in GitHub Desktop.
Save stephandesouza/26b898e4df2d163ed3eeac183daa8e0b to your computer and use it in GitHub Desktop.
Zend's CreditCard Validator with Elo and Hipercard.
<?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