\CryptoManana\Core\Traits\RandomnessStringOutputTrait

Trait StringOutputTrait - Reusable implementation of `StringOutputInterface`.

Summary

Methods
Properties
Constants
getDigit()
getLetter()
getAlphaNumeric()
getAscii()
getString()
No public properties found
No constants found
validateCharacterMap()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getDigit()

getDigit(boolean  $includeZero = true) : string

Generate a random digit character.

Parameters

boolean $includeZero

Flag for including the zero digit (default => true).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated digit character.

getLetter()

getLetter(boolean  $caseSensitive = true) : string

Generate a random english letter character.

Parameters

boolean $caseSensitive

Flag for enabling case sensitive generation (default => true).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated english letter character.

getAlphaNumeric()

getAlphaNumeric(integer  $length = 1, boolean  $caseSensitive = true) : string

Generate a random alphanumeric string.

Parameters

integer $length

The output string length (default => 1).

boolean $caseSensitive

Flag for enabling case sensitive generation (default => true).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated alphanumeric string.

getAscii()

getAscii(integer  $length = 1, boolean|integer  $includeSpace = false) : string

Generate a random ASCII (American Standard Code) string containing only printable characters.

Parameters

integer $length

The output string length (default => 1).

boolean|integer $includeSpace

Flag for including the space character (default => true).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated ASCII string.

getString()

getString(integer  $length = 1, array  $characters = array()) : string

Generate a random string with custom characters.

Parameters

integer $length

The output string length (default => 1).

array $characters

The character map for the string generation (default => ASCII).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated string using a custom character map.

validateCharacterMap()

validateCharacterMap(array  $charMap) 

Internal method for character map validation.

Parameters

array $charMap

The character map array.

Throws

\Exception

Validation errors.