Documentation

Helper
in package

A class with some methods that may make building extensions easier.

Tags
experimental

This class is experimental and does not fall under our BC promise

Table of Contents

bothify()  : 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.
lexify()  : string
Replaces all question mark ('?') occurrences with a random letter.
numerify()  : string
Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a non-zero number.
randomElement()  : mixed
Returns a random element from a passed array.
replaceWildcard()  : string

Methods

bothify()

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

public static bothify(string $string) : string
Parameters
$string : string

String that needs to bet parsed

Return values
string

lexify()

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

public static lexify(string $string) : string
Parameters
$string : string

String that needs to bet parsed

Return values
string

numerify()

Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a non-zero number.

public static numerify(string $string) : string
Parameters
$string : string

String that needs to bet parsed

Return values
string

randomElement()

Returns a random element from a passed array.

public static randomElement(array<string|int, mixed> $array) : mixed
Parameters
$array : array<string|int, mixed>
Return values
mixed

replaceWildcard()

private static replaceWildcard(string $string, string $wildcard, callable $callback) : string
Parameters
$string : string
$wildcard : string
$callback : callable
Return values
string

Search results