class GuidStringCodec extends StringCodec (View source)

GuidStringCodec encodes and decodes globally unique identifiers (GUID)

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 GUID

string
encodeBinary(UuidInterface $uuid)

Encodes a UuidInterface as a binary representation of a GUID

decode(string $encodedUuid)

Decodes a string representation of a GUID into a UuidInterface object instance

decodeBytes(string $bytes)

Decodes a binary representation of a GUID 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
swapFields(array $components)

Swaps fields to support GUID byte order

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 GUID

Parameters

UuidInterface $uuid

Return Value

string Hexadecimal string representation of a UUID

string encodeBinary(UuidInterface $uuid)

Encodes a UuidInterface as a binary representation of a GUID

Parameters

UuidInterface $uuid

Return Value

string Binary string representation of a UUID

UuidInterface decode(string $encodedUuid)

Decodes a string representation of a GUID into a UuidInterface object instance

Parameters

string $encodedUuid

Return Value

UuidInterface

UuidInterface decodeBytes(string $bytes)

Decodes a binary representation of a GUID 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 swapFields(array $components)

Swaps fields to support GUID byte order

Parameters

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

Return Value

void