eloquent/endec API
Class

Eloquent\Endec\Codec

class Codec implements CodecInterface

A general-purpose codec implementation for composing custom codecs.

Methods

__construct(TransformInterface $encodeTransform, TransformInterface $decodeTransform)

Construct a new codec.

TransformInterface encodeTransform()

Get the encode transform.

TransformInterface decodeTransform()

Get the decode transform.

string encode(string $data)

Encode the supplied data.

string decode(string $data)

Decode the supplied data.

TransformStreamInterface createEncodeStream(integer|null $bufferSize = null)

Create a new encode stream.

TransformStreamInterface createDecodeStream(integer|null $bufferSize = null)

Create a new decode stream.

Details

at line 29
public __construct(TransformInterface $encodeTransform, TransformInterface $decodeTransform)

Construct a new codec.

Parameters

TransformInterface $encodeTransform The encode transform to use.
TransformInterface $decodeTransform The decode transform to use.

at line 42
public TransformInterface encodeTransform()

Get the encode transform.

Return Value

TransformInterface The encode transform.

at line 52
public TransformInterface decodeTransform()

Get the decode transform.

Return Value

TransformInterface The decode transform.

at line 65
public string encode(string $data)

Encode the supplied data.

Parameters

string $data The data to encode.

Return Value

string The encoded data.

Exceptions

EncodingExceptionInterface If the data cannot be encoded.

at line 85
public string decode(string $data)

Decode the supplied data.

Parameters

string $data The data to decode.

Return Value

string The decoded data.

Exceptions

EncodingExceptionInterface If the data cannot be decoded.

at line 104
public TransformStreamInterface createEncodeStream(integer|null $bufferSize = null)

Create a new encode stream.

Parameters

integer|null $bufferSize The buffer size in bytes.

Return Value

TransformStreamInterface The newly created encode stream.

at line 116
public TransformStreamInterface createDecodeStream(integer|null $bufferSize = null)

Create a new decode stream.

Parameters

integer|null $bufferSize The buffer size in bytes.

Return Value

TransformStreamInterface The newly created decode stream.