Documentation

BuilderEncoder
in package
implements Encoder uses EncodeIfSupported

FinalYes
Tags
template-implements

Table of Contents

Interfaces

Encoder

Properties

$cachedEncoders  : array<class-string, Encoder|null>
$encoders  : array<class-string, Encoder>

Methods

__construct()  : mixed
canEncode()  : bool
Checks if the encoder supports a given value.
encode()  : Type|stdClass|array<string|int, mixed>|string|int
Encodes a given value. If the encoder does not support the value, it should throw an exception.
encodeIfSupported()  : mixed
getEncoderFor()  : Encoder|null

Properties

Methods

__construct()

public __construct([iterable<class-string, Encoder$encoders = [] ]) : mixed
Parameters
$encoders : iterable<class-string, Encoder> = []

canEncode()

Checks if the encoder supports a given value.

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

object $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) : Type|stdClass|array<string|int, mixed>|string|int
Parameters
$value : mixed
Return values
Type|stdClass|array<string|int, mixed>|string|int

encodeIfSupported()

public encodeIfSupported(mixed $value) : mixed
Parameters
$value : mixed
Tags
psalm-return

($value is NativeType ? BSONType : $value)


        
On this page

Search results