class BinaryCodec

Properties

static protected array<string, array{encode: callable(null|string|Ulid|Uuid): ?string, decode: callable(?string): ?string}> $customCodecs

Methods

static void
register(string $name, callable $encode, callable $decode)

Register a custom codec.

static string|null
encode(Uuid|Ulid|string|null $value, string $format)

Encode a value to binary.

static string|null
decode(string|null $value, string $format)

Decode a binary value to string.

static array
formats()

Get all available format names.

static bool
isBinary(mixed $value)

Determine if the given value is binary data.

static void
flushState()

Flush all static state.

Details

at line 22
static void register(string $name, callable $encode, callable $decode)

Register a custom codec.

Boot-only. Codecs persist in a static property for the worker lifetime and apply to every subsequent encode/decode call.

Parameters

string $name
callable $encode
callable $decode

Return Value

void

at line 33
static string|null encode(Uuid|Ulid|string|null $value, string $format)

Encode a value to binary.

Parameters

Uuid|Ulid|string|null $value
string $format

Return Value

string|null

at line 61
static string|null decode(string|null $value, string $format)

Decode a binary value to string.

Parameters

string|null $value
string $format

Return Value

string|null

at line 83
static array formats()

Get all available format names.

Return Value

array

at line 91
static bool isBinary(mixed $value)

Determine if the given value is binary data.

Parameters

mixed $value

Return Value

bool

at line 107
static void flushState()

Flush all static state.

Return Value

void