class IntegerEncoder implements Encoder (View source)

Encoder for integer values.

Methods

__construct()

IntegerEncoder constructor.

array
getDefaultOptions()

Returns a list of options and their default values as an associative array.

bool
supports(mixed $value)

Tells if the encoder supports encoding the given value.

string
encode(mixed $value, int $depth, array $options, callable $encode)

Generates the PHP code representation for the given value.

string
encodeBinary(int $integer)

Encodes an integer into binary representation.

string
encodeOctal(int $integer)

Encodes an integer into octal representation.

string
encodeDecimal(int $integer, array $options)

Encodes an integer into decimal representation.

string
encodeHexadecimal(int $integer, array $options)

Encodes an integer into hexadecimal representation.

Details

__construct()

IntegerEncoder constructor.

array getDefaultOptions()

Returns a list of options and their default values as an associative array.

Return Value

array List of options and their default values

bool supports(mixed $value)

Tells if the encoder supports encoding the given value.

Parameters

mixed $value Value to test

Return Value

bool True if the value can be encoded, false otherwise

string encode(mixed $value, int $depth, array $options, callable $encode)

Generates the PHP code representation for the given value.

Parameters

mixed $value Value to encode
int $depth Current indentation depth of the output
array $options List of encoder options
callable $encode Callback used to encode values

Return Value

string The PHP code that represents the given value

string encodeBinary(int $integer)

Encodes an integer into binary representation.

Parameters

int $integer The integer to encode

Return Value

string The PHP code representation for the integer

string encodeOctal(int $integer)

Encodes an integer into octal representation.

Parameters

int $integer The integer to encode

Return Value

string The PHP code representation for the integer

string encodeDecimal(int $integer, array $options)

Encodes an integer into decimal representation.

Parameters

int $integer The integer to encode
array $options The integer encoding options

Return Value

string The PHP code representation for the integer

string encodeHexadecimal(int $integer, array $options)

Encodes an integer into hexadecimal representation.

Parameters

int $integer The integer to encode
array $options The integer encoding options

Return Value

string The PHP code representation for the integer