alirezasalehizadeh / random
The PHP Random tool.
v1.1.0
2024-04-29 11:57 UTC
Requires
- php: ^8.3
Requires (Dev)
- pestphp/pest: 2.x-dev
This package is not auto-updated.
Last update: 2025-03-31 16:51:59 UTC
README
An PHP tool for generate random values easily.
Requirements
PHP >= 8.3
Installation
via Composer:
composer require alirezasalehizadeh/random
Usage
Integer
Generate an random int
use Alirezasalehizadeh\Random; Random::int($min = null, $max = null)
Float
Generate an random float
use Random\IntervalBoundary; use Alirezasalehizadeh\Random; Random::float($min = null, $max = null, $boundary = IntervalBoundary::ClosedOpen)
Byte
Generate an random bytes with specific length
use Alirezasalehizadeh\Random; Random::byte($length)
String
Generate an random string from given string
use Alirezasalehizadeh\Random; Random::string($bytes, $length = null)
Array
Generate an random array from given array
use Alirezasalehizadeh\Random; Random::array($array)
Pick random elements from given array
use Alirezasalehizadeh\Random; Random::pick($array, $num = 1)
Engines
Mt19937(Mersenne Twister)
use Random\Engine\Mt19937; use Alirezasalehizadeh\Random; (new Random(new Mt19937))->generate()
PcgOneseq128XslRr64
use Alirezasalehizadeh\Random; use Random\Engine\PcgOneseq128XslRr64; (new Random(new PcgOneseq128XslRr64))->generate()
Xoshiro256StarStar
use Alirezasalehizadeh\Random; use Random\Engine\Xoshiro256StarStar; (new Random(new Xoshiro256StarStar))->generate()
Contributing
Send pull request or open issue for contributing.
License
MIT.