class Company extends Company

Methods

__construct( Generator $generator)

No description

from Base
static  integer
randomDigit()

Returns a random number between 0 and 9

from Base
static  integer
randomDigitNotNull()

Returns a random number between 1 and 9

from Base
static  int
randomDigitNot( int $except)

Generates a random digit, which cannot be $except

from Base
static  integer
randomNumber( integer $nbDigits = null, boolean $strict = false)

Returns a random integer with 0 to $nbDigits digits.

from Base
static  float
randomFloat( int $nbMaxDecimals = null, int|float $min, int|float $max = null)

Return a random float number

from Base
static  integer
numberBetween( integer $int1, integer $int2 = 2147483647)

Returns a random number between $int1 and $int2 (any order)

from Base
static  string
randomLetter()

Returns a random letter from a to z

from Base
static 
randomAscii()

Returns a random ASCII character (excluding accents and special chars)

from Base
static  array
randomElements( array $array = array('a', 'b', 'c'), integer $count = 1, boolean $allowDuplicates = false)

Returns randomly ordered subsequence of $count elements from a provided array

from Base
static  mixed
randomElement( array $array = array('a', 'b', 'c'))

Returns a random element from a passed array

from Base
static  int|string|null
randomKey( array $array = array())

Returns a random key from a passed associative array

from Base
static  array|string
shuffle( array|string $arg = '')

Returns a shuffled version of the argument.

from Base
static  array
shuffleArray( array $array = array())

Returns a shuffled version of the array.

from Base
static  string
shuffleString( string $string = '', string $encoding = 'UTF-8')

Returns a shuffled version of the string.

from Base
static  string
numerify( string $string = '###')

Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number

from Base
static  string
lexify( string $string = '????')

Replaces all question mark ('?') occurrences with a random letter

from Base
static  string
bothify( string $string = '## ??')

Replaces hash signs ('#') and question marks ('?') with random numbers and letters An asterisk ('*') is replaced with either a random number or a random letter

from Base
static  string
asciify( string $string = '****')

Replaces * signs with random numbers and letters and special characters

from Base
static  string
regexify( string $regex = '')

Transforms a basic regular expression into a random string satisfying the expression.

from Base
static  string
toLower( string $string = '')

Converts string to lowercase.

from Base
static  string
toUpper( string $string = '')

Converts string to uppercase.

from Base
mixed|null
optional($weight = 0.5, $default = null)

Chainable method for making any formatter optional.

from Base
unique( boolean $reset = false, integer $maxRetries = 10000)

Chainable method for making any formatter unique.

from Base
valid( Closure $validator = null, integer $maxRetries = 10000)

Chainable method for forcing any formatter to return only valid values.

from Base
company()

No description

from Company
static 
companySuffix()

No description

from Company
jobTitle()

No description

from Company
catchPhrase()

No description

bs()

No description

Details

__construct( Generator $generator)

Parameters

Generator $generator

static integer randomDigit()

Returns a random number between 0 and 9

Return Value

integer

static integer randomDigitNotNull()

Returns a random number between 1 and 9

Return Value

integer

static int randomDigitNot( int $except)

Generates a random digit, which cannot be $except

Parameters

int $except

Return Value

int

static integer randomNumber( integer $nbDigits = null, boolean $strict = false)

Returns a random integer with 0 to $nbDigits digits.

The maximum value returned is mt_getrandmax()

Parameters

integer $nbDigits Defaults to a random number between 1 and 9
boolean $strict Whether the returned number should have exactly $nbDigits

Return Value

integer

static float randomFloat( int $nbMaxDecimals = null, int|float $min, int|float $max = null)

Return a random float number

Parameters

int $nbMaxDecimals
int|float $min
int|float $max

Return Value

float

static integer numberBetween( integer $int1, integer $int2 = 2147483647)

Returns a random number between $int1 and $int2 (any order)

Parameters

integer $int1 default to 0
integer $int2 defaults to 32 bit max integer, ie 2147483647

Return Value

integer

static string randomLetter()

Returns a random letter from a to z

Return Value

string

static randomAscii()

Returns a random ASCII character (excluding accents and special chars)

static array randomElements( array $array = array('a', 'b', 'c'), integer $count = 1, boolean $allowDuplicates = false)

Returns randomly ordered subsequence of $count elements from a provided array

Parameters

array $array Array to take elements from. Defaults to a-f
integer $count Number of elements to take.
boolean $allowDuplicates Allow elements to be picked several times. Defaults to false

Return Value

array New array with $count elements from $array

Exceptions

LengthException When requesting more elements than provided

static mixed randomElement( array $array = array('a', 'b', 'c'))

Returns a random element from a passed array

Parameters

array $array

Return Value

mixed

static int|string|null randomKey( array $array = array())

Returns a random key from a passed associative array

Parameters

array $array

Return Value

int|string|null

static array|string shuffle( array|string $arg = '')

Returns a shuffled version of the argument.

This function accepts either an array, or a string.

Parameters

array|string $arg The set to shuffle

Return Value

array|string The shuffled set

See also

shuffleArray()
shuffleString()

static array shuffleArray( array $array = array())

Returns a shuffled version of the array.

This function does not mutate the original array. It uses the Fisher–Yates algorithm, which is unbiased, together with a Mersenne twister random generator. This function is therefore more random than PHP's shuffle() function, and it is seedable.

Parameters

array $array The set to shuffle

Return Value

array The shuffled set

static string shuffleString( string $string = '', string $encoding = 'UTF-8')

Returns a shuffled version of the string.

This function does not mutate the original string. It uses the Fisher–Yates algorithm, which is unbiased, together with a Mersenne twister random generator. This function is therefore more random than PHP's shuffle() function, and it is seedable. Additionally, it is UTF8 safe if the mb extension is available.

Parameters

string $string The set to shuffle
string $encoding The string encoding (defaults to UTF-8)

Return Value

string The shuffled set

static string numerify( string $string = '###')

Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number

Parameters

string $string String that needs to bet parsed

Return Value

string

static string lexify( string $string = '????')

Replaces all question mark ('?') occurrences with a random letter

Parameters

string $string String that needs to bet parsed

Return Value

string

static string bothify( string $string = '## ??')

Replaces hash signs ('#') and question marks ('?') with random numbers and letters An asterisk ('*') is replaced with either a random number or a random letter

Parameters

string $string String that needs to bet parsed

Return Value

string

static string asciify( string $string = '****')

Replaces * signs with random numbers and letters and special characters

Parameters

string $string String that needs to bet parsed

Return Value

string

static string regexify( string $regex = '')

Transforms a basic regular expression into a random string satisfying the expression.

Parameters

string $regex A regular expression (delimiters are optional)

Return Value

string

See also

https://github.com/icomefromthenet/ReverseRegex for a more robust implementation

static string toLower( string $string = '')

Converts string to lowercase.

Uses mb_string extension if available.

Parameters

string $string String that should be converted to lowercase

Return Value

string

static string toUpper( string $string = '')

Converts string to uppercase.

Uses mb_string extension if available.

Parameters

string $string String that should be converted to uppercase

Return Value

string

mixed|null optional($weight = 0.5, $default = null)

Chainable method for making any formatter optional.

Parameters

$weight
$default

Return Value

mixed|null

UniqueGenerator unique( boolean $reset = false, integer $maxRetries = 10000)

Chainable method for making any formatter unique.

// will never return twice the same value $faker->unique()->randomElement(array(1, 2, 3));

Parameters

boolean $reset If set to true, resets the list of existing values
integer $maxRetries Maximum number of retries to find a unique value, After which an OverflowException is thrown.

Return Value

UniqueGenerator A proxy class returning only non-existing values

Exceptions

OverflowException When no unique value can be found by iterating $maxRetries times

ValidGenerator valid( Closure $validator = null, integer $maxRetries = 10000)

Chainable method for forcing any formatter to return only valid values.

The value validity is determined by a function passed as first argument.

$values = array(); $evenValidator = function ($digit) { return $digit % 2 === 0; }; for ($i=0; $i < 10; $i++) { $values []= $faker->valid($evenValidator)->randomDigit; } print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]

Parameters

Closure $validator A function returning true for valid values
integer $maxRetries Maximum number of retries to find a unique value, After which an OverflowException is thrown.

Return Value

ValidGenerator A proxy class returning only valid values

Exceptions

OverflowException When no valid value can be found by iterating $maxRetries times

company()

static companySuffix()

jobTitle()

catchPhrase()

bs()