\CryptoManana\UtilitiesElementPicker

Class ElementPicker - Utility class for random element picking.

Summary

Methods
Properties
Constants
__construct()
__destruct()
__clone()
seedRandomGenerator()
setRandomGenerator()
getRandomGenerator()
pickCharacterElement()
pickArrayElement()
$randomnessSource
No constants found
No protected methods found
$randomnessSource
N/A
No private methods found
No private properties found
N/A

Properties

$randomnessSource

$randomnessSource : \CryptoManana\Core\Abstractions\Randomness\AbstractGenerator

The pseudo-random generator service property storage.

The randomness generator.

Type

\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator — The pseudo-random generator service.

Methods

__construct()

__construct(\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator|null  $generator = null) 

Container constructor.

Parameters

\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator|null $generator

The pseudo-random generator service.

Throws

\Exception

Initialization validation.

__destruct()

__destruct() 

Container destructor.

__clone()

__clone() 

Container cloning via deep copy.

seedRandomGenerator()

seedRandomGenerator(null|integer  $seed = null) : $this

Pass a seed value to the pseudo-randomness generator service.

Parameters

null|integer $seed

Seed value in integer format or null for auto-seeding.

Throws

\Exception

Validation errors and service misuse.

Returns

$this —

The container object.

setRandomGenerator()

setRandomGenerator(\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator  $generator) : $this

Setter for the pseudo-random generator service.

Parameters

\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator $generator

The pseudo-random generator service.

Returns

$this —

The container object.

pickCharacterElement()

pickCharacterElement(string  $string = '') : string

Pick a random character from string.

Parameters

string $string

The string with characters for choosing from.

Throws

\Exception

Validation errors.

Returns

string —

The chosen character string.

pickArrayElement()

pickArrayElement(array  $array = array()) : mixed

Pick a random element from array.

Parameters

array $array

The array with elements for choosing from.

Returns

mixed —

The chosen element from the array.