atelierdisko / coupon_code
PHP library to generate and validate coupon code strings.
Installs: 155 842
Dependents: 1
Suggesters: 0
Security: 0
Stars: 59
Watchers: 8
Forks: 18
Open Issues: 2
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: >=4.0.0
Suggests
- ext-mcrypt: The mcrypt extension must be installed if /dev/urandom is not available.
This package is auto-updated.
Last update: 2024-12-23 05:19:10 UTC
README
Coupon Code -- PHP library to generate and validate coupon code strings. Synopsis -------- This library is a loose port of the CPAN module Algorithm::CouponCode[0] by Grant McLean. [0] https://github.com/grantm/Algorithm-CouponCode Copyright & License ------------------- This library is Copyright (c) 2014 Marius Wilms if not otherwise stated. The code is distributed under the terms of the BSD 3-clause License. For the full license text see the LICENSE file. Installation ------------ The preferred installation method is via composer. You can add the library as a dependency via: $ composer require atelierdisko/coupon_code Quickstart ---------- <?php use CouponCode\CouponCode; $code = new CouponCode(); $result = $code->generate(); // returns a string in `XXXX-XXXX-XXXX` format i.e. // `1K7Q-CTFM-LMTC`. $code->validate($result); // returns a boolean indicating if the code is valid. $code->normalize('i9oD_V467-8Dsz'); // returns `190D-V467-8D52` ?>