Parsable
in
Interface for custom serialization/deserialization of values.
Implement this interface on types that need custom marshalling logic beyond the default Obj serialization. Examples: Enums, Value Objects, Date/Time types.
The framework automatically calls marshall() on Parsable objects during serialization and parse() during deserialization when encountered as field types.
Tags
Table of Contents
Methods
- marshall() : mixed
- Convert this object into a marshalled representation.
- parse() : static
- Parse external data into this object.
Methods
marshall()
Convert this object into a marshalled representation.
public
marshall() : mixed
Called during serialization to convert the object into a format suitable for JSON encoding (typically a string or primitive).
Return values
mixed —The marshalled representation (string, array, etc).
parse()
Parse external data into this object.
public
parse(mixed $data) : static
Called during deserialization when this type is encountered in an Obj field.
Parameters
- $data : mixed
-
The external data to parse (typically from JSON).
Tags
Return values
static —A new instance populated with parsed data.