publero / code-generator
Publero Code Generator Component
Installs: 3 127
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 0
Open Issues: 1
Requires
- php: >=5.3.3
This package is not auto-updated.
Last update: 2024-11-09 15:05:41 UTC
README
Code Generator provides classes for simple random hash and random custom alpabet codes.
Usage
Random hash codes can be generated like this:
<?php $sha1Generator = new Sha1HashGenerator(); $sha1Hash = $sha1Generator->generate(); $md5Generator = new Md5HashGenerator(); $md5Hash = $md5Generator->generate();
And custom alphabet code example:
<?php $alphabet = 'abcdef'; $codeGenerator = new CustomAlphabetCodeGenerator($alphabet, 8); $code = $codeGenerator->generate(); // code consisting of 8 a-f characters $defaultCodeGenerator = new CustomAlphabetCodeGenerator(); $code = $codeGenerator->generate(); // generates 10 character long code of a-zA-Z0-9 characters
Resources
You can run the unit tests with the following command:
phpunit