Simple random string generator library. String generator is defined by interface \Idoheo\StringGenerator\StringGeneratorInterface.
The following string generators are pre implemented:
Generator class | Generated string |
---|---|
Idoheo\StringGenerator\StringGenerator\AlnumCharStringGenerator | Alphanumeric string with upper and lowercase chars |
Idoheo\StringGenerator\StringGenerator\HexStringGenerator | Hexadecimal string generator (lowercase chars) |
Idoheo\StringGenerator\StringGenerator\NqCharStringGenerator | NQCHAR = %x21 / %x23-5B / %x5D-7E |
Idoheo\StringGenerator\StringGenerator\NqsCharStringGenerator | NQSCHAR = %x20-21 / %x23-5B / %x5D-7E |
Idoheo\StringGenerator\StringGenerator\VsCharStringGenerator | VSCHAR = %x20-7E |
Generator class | Generated string |
---|---|
Idoheo\StringGenerator\MappedStringGenerator | String of characters provided in array passed to constructor |
To help writing your own generator, the following two abstract classes can be extended:
For this class you have to implement ::executeStringGeneration() method. $length parameter is already checked to be non-negative integer value, so no checking (and exception throwing) from your part is needed in case of invalid $length specified.
For this class you have to implement ::getCharacter() method to return next string character. As this is extending previous mentioned class, no checks on $length variable are needed.