eudiegoborgs / credit-card-pattern
PHP implementation of Credit Card Pattern
0.1.0
2024-05-31 14:28 UTC
Requires (Dev)
- phpunit/phpunit: ^9.5
README
The CreditCardPattern is a implementation of patterns to correctly handle credit card data, this is based on https://diegoborgs.com.br/blog/credit-card-pattern-como-tratar-dados-de-cart%C3%A3o-de-cr%C3%A9dito-via-c%C3%B3digo
How to use
Install with composer
composer require eudiegoborgs/credit-card-pattern
Add to your code
use EuDiegoBorgs\CreditCardPattern\Type\CreditCard; $creditCard = new CreditCard('Sherlock Holmes', '02/2099', '123', '0123456789012345'); echo $creditCard->isExpired(); // false echo (string) $creditCard->getBin(); // 012345 echo (string) $creditCard->getLastFour(); // 2345 var_dump($creditCard->toArray()); /** * Prints this data * [ * 'holderName' => 'Sherlock Holmes', * 'validThru' => '02/2099', * 'cvv' => '123', * 'number' => '0123456789012345', * 'bin' => '012345', * 'lastFour' => '2345', * ]
Contributing
Fork the project and send your PR.
Running the Tests
Install the Composer dependencies:
git clone https://github.com/eudiegoborgs/credit-card-pattern.git
cd credit-card-pattern
Then run the test suite:
composer test
License
This bundle is released under the MIT license.