Documentation

Bytes
in package

Wrapper around a string that contains raw bytes

Table of Contents

$bytes  : string
__construct()  : mixed
__toString()  : string
Printable hex representation of the held bytes. To return the held bytes themselves, use `getByteString()`.
byteSlice()  : Bytes
Gets a slice of the held bytes.
concat()  : Bytes
Concatenates the held bytes with the provided bytes.
fromBase64()  : Bytes
Constructs Bytes from a base64-encoded string. Holds the decoded bytes. If the input is not valid base64 an InvalidArgumentException will be thrown.
getAtIndex()  : Bytes
Gets the byte at the provided index.
getBase64String()  : string
Gets the base64-encoded representation of the held bytes.
getByteString()  : string
Gets the held byte string.
getHexString()  : string
Printable hex representation of the held bytes. To return the held bytes themselves, use `getByteString()`.
length()  : int
Gets the length of the held bytes.

Properties

$bytes

private string $bytes

Methods

__construct()

public __construct(string $bytes) : mixed
Parameters
$bytes : string
Return values
mixed

__toString()

Printable hex representation of the held bytes. To return the held bytes themselves, use `getByteString()`.

public __toString() : string
Return values
string

Hex representation of held bytes

byteSlice()

Gets a slice of the held bytes.

public byteSlice(int $offset[, int|null $length = null ]) : Bytes

Internally calls substr on the held bytes. Refer to its documentation for more information.

Parameters
$offset : int
$length : int|null = null
Return values
Bytes

concat()

Concatenates the held bytes with the provided bytes.

public concat(Bytes $other) : Bytes
Parameters
$other : Bytes

Bytes to go on the end of the held bytes

Return values
Bytes

The held bytes concatenated with the provided bytes

fromBase64()

Constructs Bytes from a base64-encoded string. Holds the decoded bytes. If the input is not valid base64 an InvalidArgumentException will be thrown.

public static fromBase64(string $base64String) : Bytes
Parameters
$base64String : string
Return values
Bytes

Bytes object holding the base64-decoded bytes

getAtIndex()

Gets the byte at the provided index.

public getAtIndex(int $index) : Bytes
Parameters
$index : int

Index to get the byte at

Return values
Bytes

The single byte located at the index

getBase64String()

Gets the base64-encoded representation of the held bytes.

public getBase64String() : string
Return values
string

Base64-encoded string representing the held bytes

getByteString()

Gets the held byte string.

public getByteString() : string

This string is likely not printable. See getHexString() for a printable representation of the bytes.

Return values
string

The held bytes

getHexString()

Printable hex representation of the held bytes. To return the held bytes themselves, use `getByteString()`.

public getHexString() : string
Return values
string

Hex representation of held bytes

length()

Gets the length of the held bytes.

public length() : int
Return values
int

Length of held bytes

Search results