ChainEncoder
in package
implements
ContextAwareEncoderInterface
Encoder delegating the decoding to a chain of encoders.
Tags
Table of Contents
Interfaces
- ContextAwareEncoderInterface
- Adds the support of an extra $context parameter for the supportsEncoding method.
Properties
- $encoderByFormat : array<string|int, mixed>
- $encoders : array<string|int, mixed>
Methods
- __construct() : mixed
- encode() : string
- {@inheritdoc}
- needsNormalization() : bool
- Checks whether the normalization is needed for the given format.
- supportsEncoding() : bool
- Checks whether the serializer can encode to given format.
- getEncoder() : EncoderInterface
- Gets the encoder supporting the format.
Properties
$encoderByFormat
private
array<string|int, mixed>
$encoderByFormat
= []
$encoders
private
array<string|int, mixed>
$encoders
= []
Methods
__construct()
public
__construct([array<string|int, mixed> $encoders = [] ]) : mixed
Parameters
- $encoders : array<string|int, mixed> = []
encode()
{@inheritdoc}
public
final encode(mixed $data, string $format[, array<string|int, mixed> $context = [] ]) : string
Parameters
- $data : mixed
- $format : string
- $context : array<string|int, mixed> = []
Return values
stringneedsNormalization()
Checks whether the normalization is needed for the given format.
public
needsNormalization(string $format[, array<string|int, mixed> $context = [] ]) : bool
Parameters
- $format : string
- $context : array<string|int, mixed> = []
Return values
boolsupportsEncoding()
Checks whether the serializer can encode to given format.
public
supportsEncoding(string $format[, array<string|int, mixed> $context = [] ]) : bool
Parameters
- $format : string
-
Format name
- $context : array<string|int, mixed> = []
-
options that encoders have access to
Return values
boolgetEncoder()
Gets the encoder supporting the format.
private
getEncoder(string $format, array<string|int, mixed> $context) : EncoderInterface
Parameters
- $format : string
- $context : array<string|int, mixed>