Table of contents
Namespace: Com\Tecnick\File
class Byte
Source: src/Byte.php:40
Big-endian byte-level reads from a binary string
The 32-bit readers (getULong(), getLong(), getFixed()) assume a 64-bit PHP build: on a 32-bit build the intermediate left shift overflows the platform integer.
Methods
__construct()
Initialize a new string to be processed.
public __construct(string $str)
Parameters:
$str(string): String (binary) from where to extract values
Source: src/Byte.php:52
getByte()
Get BYTE from string (8-bit unsigned integer).
public getByte(int $offset): int
Parameters:
$offset(int): Point from where to read the data.
Returns: int: 8 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:93
getFixed()
Get FIXED from string (Big Endian 32-bit signed fixed-point number (16.16)).
A fixed-point 16.16 number is the signed int16 integer part plus the unsigned 16-bit fractional part divided by 65536 = (1 << 16).
public getFixed(int $offset): float
Parameters:
$offset(int): Point from where to read the data.
Returns: float: Fixed-point value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:245
getFWord()
Get FWORD from string (Big Endian 16-bit signed integer).
Alias for getShort().
public getFWord(int $offset): int
Parameters:
$offset(int): Point from where to read the data.
Returns: int: 16 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:171
getLength()
Get the length of the binary string in bytes.
public getLength(): int
Returns: int
Source: src/Byte.php:64
getLong()
Get LONG from string (Big Endian 32-bit signed integer).
public getLong(int $offset): int
Parameters:
$offset(int): Point from where to read the data
Returns: int: 32 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:216
getShort()
Get SHORT from string (Big Endian 16-bit signed integer).
public getShort(int $offset): int
Parameters:
$offset(int): Point from where to read the data.
Returns: int: 16 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:129
getUFWord()
Get UFWORD from string (Big Endian 16-bit unsigned integer).
Alias for getUShort().
public getUFWord(int $offset): int
Parameters:
$offset(int): Point from where to read the data.
Returns: int: 16 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:152
getULong()
Get ULONG from string (Big Endian 32-bit unsigned integer).
public getULong(int $offset): int
Parameters:
$offset(int): Point from where to read the data
Returns: int: 32 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:193
getUShort()
Get USHORT from string (Big Endian 16-bit unsigned integer).
public getUShort(int $offset): int
Parameters:
$offset(int): Point from where to read the data
Returns: int: 16 bit value
Throws:
RangeException: if the requested read is out of bounds.
Source: src/Byte.php:111