\CryptoManana\Core\Traits\RandomnessArbitraryBaseOutputTrait

Trait ArbitraryBaseOutputTrait - Reusable implementation of `ArbitraryBaseOutputInterface`.

Summary

Methods
Properties
Constants
getBool()
getTernary()
getHex()
getBase64()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getBool()

getBool() : boolean

Generate a random boolean.

Throws

\Exception

Validation errors.

Returns

boolean —

Randomly generated boolean value.

getTernary()

getTernary(boolean|integer  $asInteger = true) : boolean|integer

Generate a random ternary format (-1, 0, 1).

Note: Passing false to the $asInteger parameter will convert values to null, false and true.

Parameters

boolean|integer $asInteger

Flag for returning as integer (default => true).

Throws

\Exception

Validation errors.

Returns

boolean|integer —

Randomly generated ternary value.

getHex()

getHex(integer  $length = 1, boolean  $upperCase = false) : string

Generate a random HEX string.

Parameters

integer $length

The output string length (default => 1).

boolean $upperCase

Flag for using uppercase output (default => false).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated HEX string.

getBase64()

getBase64(integer  $length = 1, boolean  $urlFriendly = false) : string

Generate a random Base64 string.

Parameters

integer $length

The internal byte string length (default => 1).

boolean $urlFriendly

Flag for using URL friendly output (default => false).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated Base64 RFC 4648 standard string.