\CryptoManana\Core\Abstractions\RandomnessAbstractRandomness

Class AbstractRandomness - The computer randomness abstraction representation.

Summary

Methods
Properties
Constants
getMaxNumber()
getMinNumber()
__construct()
getInt()
getBytes()
No public properties found
No constants found
validateIntegerRange()
validatePositiveInteger()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getMaxNumber()

getMaxNumber() : integer

The maximum supported integer.

Returns

integer —

The upper integer generation border.

getMinNumber()

getMinNumber() : integer

The minimum supported integer.

Returns

integer —

The lower integer generation border.

__construct()

__construct() 

Randomness source constructor.

getInt()

getInt(null|integer  $from, null|integer  $to = null) : integer

Generate a random integer number in a certain range.

Note: Passing null will use the default parameter value.

Parameters

null|integer $from

The lowest value to be returned (default => 0).

null|integer $to

The highest value to be returned (default => $this->getMaxNumber()).

Returns

integer —

Randomly generated integer number.

getBytes()

getBytes(integer  $length = 1) : string

Generate a random byte string.

Note: PHP represents bytes as characters to make byte strings.

Parameters

integer $length

The output string length (default => 1).

Returns

string —

Randomly generated string containing the requested number of bytes.

validateIntegerRange()

validateIntegerRange(integer  $from, integer  $to) 

Internal method for integer range validation.

Parameters

integer $from

The minimum number in the wanted range.

integer $to

The maximum number in the wanted range.

Throws

\Exception

Validation errors.

validatePositiveInteger()

validatePositiveInteger(integer  $integer, boolean  $includeZero = false) 

Internal method for validation of positive integers.

Parameters

integer $integer

The positive integer value.

boolean $includeZero

Flag for enabling the zero as a valid value.

Throws

\Exception

Validation errors.