Random

This is a simple way to generate test data quickly then spend time on more important things.

$random = new \Samy\Dummy\Random();

Base Operations

boolean

Retrieve random boolean.

$boolean = $random->boolean();

integer

Retrieve random integer.

$integer = $random->integer($min = PHP_INT_MIN, $max = PHP_INT_MAX);

float

Retrieve random float.

$float = $random->float($min = PHP_INT_MIN, $max = PHP_INT_MAX, $precision = 2);

string

Retrieve random string.

$string = $random->string($length = 8, $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~+/");

mixed

Retrieve random mixed.

$mixed = $random->mixed();

option

Retrieve one of an array element.

$mixed = $random->option($array);

Generic Operations

name

Retrieve random name.

$name = $random->name($size = 1);

word

Retrieve random word.

$word = $random->word($size = 1);

Color Operations

rgb

Retrieve random hex RGB color.

$rgb = $random->rgb();

argb

Retrieve random hex ARGB color.

$argb = $random->argb();

Date Time Operations

date

Retrieve random date.

$date = $random->date($from = date("Y-m-d", strtotime("-5 years")), $to = date("Y-m-d", strtotime("+5 years")));

time

Retrieve random time.

$time = $random->time();

datetime

Retrieve random datetime.

$datetime = $random->datetime($from = date("Y-m-d H:i:s", strtotime("-5 years")), $to = date("Y-m-d H:i:s", strtotime("+5 years")));

Location Operations

address

Retrieve random address.

$address = $random->address();

city

Retrieve random city.

$city = $random->city();

country

Retrieve random country.

$country = $random->country();

postal

Retrieve random postal.

$postal = $random->postal();

Corporate Operations

company

Retrieve random company.

$company = $random->company();

department

Retrieve random department.

$department = $random->department();

product

Retrieve random product.

$product = $random->product();

profession

Retrieve random profession.

$profession = $random->profession();

Contact Operations

phone

Retrieve random phone.

$phone = $random->phone();

email

Retrieve random email.

$email = $random->email();

Domain Operations

tld

Retrieve random top level domain.

$tld = $random->tld();

domain

Retrieve random domain name.

$domain = $random->domain();

website

Retrieve random website name.

$website = $random->website();

url

Retrieve random url.

$url = $random->url();

Data Provider

add

Return an instance with provided data.

$random = $random->add($name, $data);

data

Retrieve one of value from provided data.

$mixed = $random->data($name);