DocumentCodec
extends
Codec
in
The DocumentCodec interface allows decoding BSON document data to native PHP objects and back to BSON documents.
Tags
Table of Contents
Methods
- canDecode() : bool
- Checks if the decoder supports a given value.
- canEncode() : bool
- Checks if the encoder supports a given value.
- decode() : object
- Decodes a given value. If the decoder does not support the value, it should throw an exception.
- decodeIfSupported() : mixed
- Decodes a given value if supported, otherwise returns the value as-is.
- encode() : Document
- Encodes a given value. If the encoder does not support the value, it should throw an exception.
- encodeIfSupported() : mixed
- Encodes a given value if supported, otherwise returns the value as-is.
Methods
canDecode()
Checks if the decoder supports a given value.
public
canDecode(mixed $value) : bool
Parameters
- $value : mixed
Tags
Return values
boolcanEncode()
Checks if the encoder supports a given value.
public
canEncode(mixed $value) : bool
Parameters
- $value : mixed
Tags
Return values
booldecode()
Decodes a given value. If the decoder does not support the value, it should throw an exception.
public
decode(mixed $value) : object
Parameters
- $value : mixed
Tags
Return values
objectdecodeIfSupported()
Decodes a given value if supported, otherwise returns the value as-is.
public
decodeIfSupported(mixed $value) : mixed
The DecodeIfSupported trait provides a default implementation of this method.
Parameters
- $value : mixed
Tags
encode()
Encodes a given value. If the encoder does not support the value, it should throw an exception.
public
encode(mixed $value) : Document
Parameters
- $value : mixed
Tags
Return values
DocumentencodeIfSupported()
Encodes a given value if supported, otherwise returns the value as-is.
public
encodeIfSupported(mixed $value) : mixed
The EncodeIfSupported trait provides a default implementation of this method.
Parameters
- $value : mixed