Class Convert
The Convert class is a static facade built around the singleton instance of the Serializer class.
This facade is only intended for prototyping and simple scripts. For larger applications it's recommended to manage
a Serializer instance with dependency injection.
Methods summary
public static
string
|
#
toJson( mixed $data )
Returns the provided $data in JSON encoded form.
Returns the provided $data in JSON encoded form.
Parameters
Returns
string
|
public static
mixed
|
#
fromJson( string $json, string|null $typeHint = null )
Returns the data in the provided $json data as a PHP value.
Returns the data in the provided $json data as a PHP value.
If the $typeHint parameter is provided, the result will be an object of that type populated with the $json data.
Parameters
Returns
mixed
|
public static
object
|
#
cast( object $instance, string $type )
Casts the provided $instance into the specified $type by serializing the $instance and deserializing it into the
specified $type.
Casts the provided $instance into the specified $type by serializing the $instance and deserializing it into the
specified $type.
Parameters
Returns
object
|