Pimple Service Provider for creating a Random Generator from ircmaxells' RandomLib
$ composer require germania-kg/random
<?php
use Germania\Random\RandomServiceProvider;
// A. Use with Slim or Pimple
$app = new \Slim\App;
$dic = $app->getContainer();
$dic = new Pimple\Container;
// B. Register Service Provider.
// Optionally pass length and strenth:
$rsp = new RandomServiceProvider;
$rsp = new RandomServiceProvider( 240, 5);
$dic->register( $rsp );
Returns a RandomLib\Generator instance. See RandomLib docs on how to deal with it.
$generator = $dic['RandomGenerator'];
$str = $generator->generateString(32, 'abcdef');
Returns a Callable wrapper around the RandomLib\Generator instance which creates a random string af arbitrary length. The callable accepts an optional string length.
$random_callable = $dic['RandomGenerator.Callable'];
$str = $random_callable(); // 256 characters
$str = $random_callable( 256 ); // 256 chars
$str = $random_callable( 64 ); // 64 chars.
Returns the \SecurityLib\Strength instance used for creating the RandomLib\Generator
$strength = $dic['RandomGenerator.Strength'];
Returns the default length of generated random strings.
$length = $dic['RandomGenerator.Length'];
$ git clone https://github.com/GermaniaKG/Random.git
$ cd Random
$ composer install
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test
# or
$ vendor/bin/phpunit