idoheo / string-generator
随机字符串生成库
dev-master
2017-06-28 13:16 UTC
Requires
- php: ~7.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.3
- phpunit/phpunit: ~6.1
This package is not auto-updated.
Last update: 2024-09-24 16:46:42 UTC
README
简单的随机字符串生成库。字符串生成器由接口 \Idoheo\StringGenerator\StringGeneratorInterface 定义。
实现了0配置字符串生成器
以下字符串生成器已预实现
实现了可配置字符串生成器
编写自己的生成器
为了帮助您编写自己的生成器,以下两个抽象类可以被扩展
\Idoheo\StringGenerator\AbstractStringGenerator
对于这个类,您必须实现 ::executeStringGeneration() 方法。参数 $length 已经检查为非负整数,因此不需要您进行任何检查(和抛出异常)来处理无效的 $length。
\Idoheo\StringGenerator\SimplifiedAbstractStringGenerator
对于这个类,您必须实现 ::getCharacter() 方法以返回下一个字符串字符。由于它扩展了前面提到的类,因此不需要对 $length 变量进行检查。