Documentation

Encoder

Tags
psalm-template

BSONType

psalm-template

NativeType

Table of Contents

Methods

canEncode()  : bool
Checks if the encoder supports a given value.
encode()  : mixed
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

canEncode()

Checks if the encoder supports a given value.

public canEncode(mixed $value) : bool
Parameters
$value : mixed
Tags
psalm-assert-if-true

NativeType $value

Return values
bool

encode()

Encodes a given value. If the encoder does not support the value, it should throw an exception.

public encode(mixed $value) : mixed
Parameters
$value : mixed
Tags
psalm-param

NativeType $value

psalm-return

BSONType

throws
UnsupportedValueException

if the encoder does not support the value

encodeIfSupported()

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
Tags
psalm-return

($value is NativeType ? BSONType : $value)


        
On this page

Search results