YamlEncoder
in package
implements
EncoderInterface, DecoderInterface
Encodes YAML data.
Tags
Table of Contents
Interfaces
Constants
- FORMAT = 'yaml'
- PRESERVE_EMPTY_OBJECTS = 'preserve_empty_objects'
- YAML_FLAGS = 'yaml_flags'
- YAML_INDENT = 'yaml_indent'
- YAML_INLINE = 'yaml_inline'
- ALTERNATIVE_FORMAT = 'yml'
Properties
- $defaultContext : mixed
- $dumper : mixed
- $parser : mixed
Methods
- __construct() : mixed
- decode() : mixed
- Decodes a string into PHP data.
- encode() : string
- Encodes data into the given format.
- supportsDecoding() : bool
- Checks whether the deserializer can decode from given format.
- supportsEncoding() : bool
- Checks whether the serializer can encode to given format.
Constants
FORMAT
public
mixed
FORMAT
= 'yaml'
PRESERVE_EMPTY_OBJECTS
public
mixed
PRESERVE_EMPTY_OBJECTS
= 'preserve_empty_objects'
YAML_FLAGS
public
mixed
YAML_FLAGS
= 'yaml_flags'
YAML_INDENT
public
mixed
YAML_INDENT
= 'yaml_indent'
YAML_INLINE
public
mixed
YAML_INLINE
= 'yaml_inline'
ALTERNATIVE_FORMAT
private
mixed
ALTERNATIVE_FORMAT
= 'yml'
Properties
$defaultContext
private
mixed
$defaultContext
= [self::YAML_INLINE => 0, self::YAML_INDENT => 0, self::YAML_FLAGS => 0]
$dumper
private
mixed
$dumper
$parser
private
mixed
$parser
Methods
__construct()
public
__construct([Dumper $dumper = null ][, Parser $parser = null ][, array<string|int, mixed> $defaultContext = [] ]) : mixed
Parameters
decode()
Decodes a string into PHP data.
public
decode(string $data, string $format[, array<string|int, mixed> $context = [] ]) : mixed
Parameters
- $data : string
-
Data to decode
- $format : string
-
Format name
- $context : array<string|int, mixed> = []
-
Options that decoders have access to
The format parameter specifies which format the data is in; valid values depend on the specific implementation. Authors implementing this interface are encouraged to document which formats they support in a non-inherited phpdoc comment.
encode()
Encodes data into the given format.
public
encode(mixed $data, string $format[, array<string|int, mixed> $context = [] ]) : string
Parameters
- $data : mixed
-
Data to encode
- $format : string
-
Format name
- $context : array<string|int, mixed> = []
-
Options that normalizers/encoders have access to
Return values
stringsupportsDecoding()
Checks whether the deserializer can decode from given format.
public
supportsDecoding(string $format) : bool
Parameters
- $format : string
-
Format name
Return values
boolsupportsEncoding()
Checks whether the serializer can encode to given format.
public
supportsEncoding(string $format) : bool
Parameters
- $format : string
-
Format name