Google API Core Client - Class Serializer (1.35.0)

Reference documentation and code samples for the Google API Core Client class Serializer.

Collection of methods to help with serialization of protobuf objects

Namespace

Google \ ApiCore

Methods

__construct

Serializer constructor.

Parameters
Name Description
fieldTransformers array

An array mapping field names to transformation functions

messageTypeTransformers array

An array mapping message names to transformation functions

decodeFieldTransformers array

An array mapping field names to transformation functions

decodeMessageTypeTransformers array

An array mapping message names to transformation functions

customEncoders mixed

encodeMessage

Encode protobuf message as a PHP array

Parameter
Name Description
message mixed
Returns
Type Description
array

decodeMessage

Decode PHP array into the specified protobuf message

Parameters
Name Description
message mixed
data array
Returns
Type Description
mixed

static::serializeToJson

Parameter
Name Description
message Google\Protobuf\Internal\Message
Returns
Type Description
string Json representation of $message

static::serializeToPhpArray

Parameter
Name Description
message Google\Protobuf\Internal\Message
Returns
Type Description
array PHP array representation of $message

static::decodeMetadata

Decode metadata received from gRPC status object

Parameter
Name Description
metadata array
Returns
Type Description
array

static::decodeAnyMessages

Decode an array of Any messages into a printable PHP array.

Parameter
Name Description
anyArray iterable
Returns
Type Description
array

static::getGetter

Parameter
Name Description
name string
Returns
Type Description
string Getter function

static::getSetter

Parameter
Name Description
name string
Returns
Type Description
string Setter function

static::toSnakeCase

Convert string from camelCase to snake_case

Parameter
Name Description
key string
Returns
Type Description
string

static::toCamelCase

Convert string from snake_case to camelCase

Parameter
Name Description
key string
Returns
Type Description
string

static::loadKnownMetadataTypes

Constants

MAP_KEY_FIELD_NAME

Value: 'key'

MAP_VALUE_FIELD_NAME

Value: 'value'