hylianshield / number-generator
Generate numbers.
Installs: 5 363
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^5.7.5
This package is auto-updated.
Last update: 2024-10-29 04:53:12 UTC
README
Generate a number or a list of numbers between a given minimum and maximum. The default implementation is based on the CSPRNG implementation introduced in PHP 7.
Installation
composer require hylianshield/number-generator:^1.0
Usage
<?php use HylianShield\NumberGenerator\NumberGenerator; $generator = new NumberGenerator(); $generator->generateNumber(); // Number between 0 and PHP_INT_MAX $generator->generateNumber(12); // Number between 12 and PHP_INT_MAX $generator->generateNumber(42, 1337); // Number between 42 and 1337 // List of 10 numbers between 42 and 1337. $numbers = iterator_to_array( $generator->generateList(10, 42, 1337) );
To generate an example, try running:
composer example 10 42 1337
Output will be similar to:
> ./examples/basic-range.php '10' '42' '1337'
685
993
472
977
876
997
459
281
529
1287