class ArrayDigitList extends AbstractDigitList (View source)

Handles a list of digits provided as an array.

Properties

protected array $digits from AbstractDigitList
protected int[] $valueMap from AbstractDigitList
protected bool $caseSensitive from AbstractDigitList
protected bool $stringConflict from AbstractDigitList

Methods

setValueMap(array $map)

Sets the value map and determines if it's case sensitive.

bool
hasStringConflict()

Tells if there is conflict that prevents numbers from being represented as a string.

bool
isCaseSensitive()

Tells if the digits are case sensitive or not.

array
getDigits()

Returns all the digits in the list.

mixed
getDigit(int $value)

Returns the digit that represents the given value.

int
getValue(mixed $digit)

Returns the value for the given digit.

int
count()

Returns the number of different digits.

__construct(array $digits)

Creates a new instance of ArrayDigitList.

Details

protected setValueMap(array $map)

Sets the value map and determines if it's case sensitive.

Parameters

array $map List of values for digits

bool hasStringConflict()

Tells if there is conflict that prevents numbers from being represented as a string.

Return Value

bool True if a number cannot be represented using a string, false if it can

bool isCaseSensitive()

Tells if the digits are case sensitive or not.

Return Value

bool True if the digits are case sensitive, false if not

array getDigits()

Returns all the digits in the list.

Return Value

array List of digits in the list according to their value

mixed getDigit(int $value)

Returns the digit that represents the given value.

Parameters

int $value The value of the digit

Return Value

mixed The digit that represents the value

Exceptions

InvalidArgumentException If the value is invalid

int getValue(mixed $digit)

Returns the value for the given digit.

Parameters

mixed $digit Digit to search for

Return Value

int The value of the digit

Exceptions

InvalidDigitException if the digit is invalid

int count()

Returns the number of different digits.

Return Value

int the number of different digits

__construct(array $digits)

Creates a new instance of ArrayDigitList.

The list of digits is provided as an array. The index provides value for the digits and the values provide the digits themselves. Any kind of value is an acceptable digit, but note that the digits are considered duplicate if their values are equal using a loose comparison.

Parameters

array $digits The list of digits for the numeral system

Exceptions

InvalidArgumentException If the list of digits is invalid