class TimestampFirstCombCodec extends StringCodec (View source)

TimestampLastCombCodec encodes and decodes COMB UUIDs which have the timestamp as the first 48 bits.

To be used with MySQL, PostgreSQL, Oracle.

Methods

__construct(UuidBuilderInterface $builder)

Constructs a StringCodec for use encoding and decoding UUIDs

string
encode(UuidInterface $uuid)

Encodes a UuidInterface as a string representation of a timestamp first COMB UUID

string
encodeBinary(UuidInterface $uuid)

Encodes a UuidInterface as a binary representation of timestamp first COMB UUID

decode(string $encodedUuid)

Decodes a string representation of timestamp first COMB UUID into a UuidInterface object instance

decodeBytes(string $bytes)

Decodes a binary representation of timestamp first COMB UUID into a UuidInterface object instance

getBuilder()

Returns the UUID builder

array
extractComponents(string $encodedUuid)

Returns an array of UUID components (the UUID exploded on its dashes)

array
getFields(array $components)

Returns the fields that make up this UUID

void
swapTimestampAndRandomBits(array $components)

Swaps the first 48 bits with the last 48 bits

Details

__construct(UuidBuilderInterface $builder)

Constructs a StringCodec for use encoding and decoding UUIDs

Parameters

UuidBuilderInterface $builder The UUID builder to use when encoding UUIDs

string encode(UuidInterface $uuid)

Encodes a UuidInterface as a string representation of a timestamp first COMB UUID

Parameters

UuidInterface $uuid

Return Value

string Hexadecimal string representation of a UUID

string encodeBinary(UuidInterface $uuid)

Encodes a UuidInterface as a binary representation of timestamp first COMB UUID

Parameters

UuidInterface $uuid

Return Value

string Binary string representation of a UUID

UuidInterface decode(string $encodedUuid)

Decodes a string representation of timestamp first COMB UUID into a UuidInterface object instance

Parameters

string $encodedUuid

Return Value

UuidInterface

UuidInterface decodeBytes(string $bytes)

Decodes a binary representation of timestamp first COMB UUID into a UuidInterface object instance

Parameters

string $bytes

Return Value

UuidInterface

protected UuidBuilderInterface getBuilder()

Returns the UUID builder

Return Value

UuidBuilderInterface

protected array extractComponents(string $encodedUuid)

Returns an array of UUID components (the UUID exploded on its dashes)

Parameters

string $encodedUuid

Return Value

array

protected array getFields(array $components)

Returns the fields that make up this UUID

Parameters

array $components

Return Value

array

See also

UuidInterface::getFieldsHex

protected void swapTimestampAndRandomBits(array $components)

Swaps the first 48 bits with the last 48 bits

Parameters

array $components An array of UUID components (the UUID exploded on its dashes)

Return Value

void