carvinglabs / code-generator
Provide a simple way to generate unique codes based on a RegExp.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 8 596
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~5.6|~7.0
- fzaninotto/faker: ^1.6
Requires (Dev)
- phpunit/phpunit: ~5.0||~6.0
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2019-08-14 07:29:28 UTC
README
code-generator
is a tool allowing you to generatate random codes based on a RegExp. In addition, you can make it unique and compare it to an existing Dataset.
Install
Via Composer
$ composer require carvinglabs/code-generator
Usage
- Generate a simple code :
$codeGenerator = new CodeGenerator(); $code = $codeGenerator->generate(); // return 'AZER1234' for instance
- Generate a code based on a custom RegExp :
$codeGenerator = new CodeGenerator(); $codeGenerator->setRules('([0-9]{4,4})'); $code = $codeGenerator->generate(); // return '1234' for instance
- Generate an unique code :
$existingCodes = ['AZER1234', 'QSDF5678', 'WXCV3456']; $codeGenerator = new CodeGenerator(); $code = $codeGenerator->generateUnique($existingCodes); // return 'REZA4321' for instance
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email julien.bonvarlet@carvinglabs.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.