Index Documentation

IntegerBaseConverter
in package

Provides methods for encoding integers in different bases.

Table of Contents

Methods

__construct()  : mixed
decode()  : int|false
Converts another base encoded integer to a base10 integer.
encode()  : string
Converts a positive base10 integer to another base.

Methods

__construct()

public __construct(string $characterSet) : mixed
Parameters
$characterSet : string

Specifies the provided character set, must be a string consisting out of at least two unique characters.

Tags
throws
InvalidArgumentException

If $characterSet contains less than two characters.

throws
InvalidArgumentException

If $characterSet contains duplicate characters.

decode()

Converts another base encoded integer to a base10 integer.

public decode(string $string[, int $fromBase = 0 ]) : int|false
Parameters
$string : string

The encoded integer.

$fromBase : int = 0

Source base, 0 for the base of the provided character set.

Return values
int|false

Returns the decoded integer or false on failure.

encode()

Converts a positive base10 integer to another base.

public encode(int $integer[, int $toBase = 0 ]) : string
Parameters
$integer : int

The integer to encode.

$toBase : int = 0

Target base, 0 for the base of the provided character set.

Return values
string

The encoded data, as a string.


        
On this page

Search results