NumberEncodingUtils
in package
A class for encoding and decoding numeric values according to the EO protocol.
This class provides functions for encoding and decoding numeric values into a format that is compatible with the EO protocol requirements. The encoding format is a variable-length encoding that uses a sequence of bytes to represent integers up to the size of an unsigned four-byte integer.
Table of Contents
Methods
- decodeNumber() : int
- Decodes a string of bytes back into an integer, according to the EO protocol encoding specification.
- encodeNumber() : array<string|int, int>
- Encodes a numeric value into a sequence of bytes, ensuring compatibility with the EO data size specifications.
Methods
decodeNumber()
Decodes a string of bytes back into an integer, according to the EO protocol encoding specification.
public
static decodeNumber(array<string|int, int> $encodedNumber) : int
This function reverses the operation performed by encodeNumber, turning a sequence of bytes back into the original integer value. It supports decoding from sequences up to four bytes long.
Parameters
- $encodedNumber : array<string|int, int>
-
The encoded number as a string of bytes.
Return values
int —The decoded integer.
encodeNumber()
Encodes a numeric value into a sequence of bytes, ensuring compatibility with the EO data size specifications.
public
static encodeNumber(int $number) : array<string|int, int>
This function is used to convert a numeric integer into a specific format that uses variable length encoding based on the EO protocol requirements. It supports encoding integers up to the size of an unsigned four-byte integer.
Parameters
- $number : int
-
The number to encode.
Return values
array<string|int, int> —The encoded number as a string of bytes.