2017 © Pedro Peláez
 

library phprandom

Random data generation

image

tkjn/phprandom

Random data generation

  • Tuesday, February 21, 2017
  • by tkjn
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

PHP Random

Build Status, (*1)

The purposes of this library are: - Provide a self-contained seeded number generator object, which doesn't rely on global state for the seed - Define interfaces for random data generation that can be type-hinted and are easy to mock when unit testing., (*2)

Installation

Require tkjn/phprandom in composer.json, (*3)

Usage

$random = new \Tkjn\Random\Integer\XorshiftStar();

// Generate random value between 10 and 100 (inclusive)
$randomNumber = $random->rand(10, 100);

Multiple instances will maintain their own seed unlike the built-in php rand() and mt_rand() which are seeded globally, (*4)

$random1 = new \Tkjn\Random\Integer\XorshiftStar(123);
$random2 = new \Tkjn\Random\Integer\XorshiftStar(123);
$random3 = new \Tkjn\Random\Integer\XorshiftStar(85874);

var_dump($random1->rand(10, 90));
var_dump($random2->rand(10, 90));
var_dump($random3->rand(10, 90));

var_dump($random1->rand(10, 90));
var_dump($random2->rand(10, 90));
var_dump($random3->rand(10, 90));

Results in, (*5)

int(59)
int(59)
int(13)

int(84)
int(84)
int(15)

The Versions

21/02 2017

dev-master

9999999-dev

Random data generation

  Sources   Download

The Requires

  • php ^7.1

 

The Development Requires

by Avatar tkjn

21/02 2017

v2.0.0

2.0.0.0

Random data generation

  Sources   Download

The Requires

  • php ^7.1

 

The Development Requires

by Avatar tkjn

08/01 2017

v1.0.0

1.0.0.0

Random data generation

  Sources   Download

The Requires

  • php ^7.1

 

The Development Requires

by Avatar tkjn

08/01 2017

dev-php7+xorshiftstar

dev-php7+xorshiftstar

Random data generation

  Sources   Download

The Requires

  • php ^7.1

 

The Development Requires

by Avatar tkjn

08/03 2015

v0.1.0

0.1.0.0

Random data generation

  Sources   Download

The Requires

  • tkjn/phptestproviders 0.1.*

 

The Development Requires

by Avatar tkjn