\Google\AdsApi\Common\UtilMapEntries

Static utility methods for working with ads `MapEntry` objects.

Summary

Methods
Properties
Constants
toAssociativeArray()
fromAssociativeArray()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
__construct()
No private properties found
N/A

Methods

toAssociativeArray()

toAssociativeArray(array  $mapEntriesList): array

Transforms list of map entries to a PHP associative array. Each map entry is expected to be a `[Key]_[Value]MapEntry` that contains a key field and a value field.

For example, if the list of map entries were:

[
  (String_StringMapEntry: key => 'animal', value => 'sheep'),
  (String_StringMapEntry: key => 'spirit_animal', value => 'bear'),
  (String_StringMapEntry: key => 'primal_animal', value => 'sloth')
]

Then this method would return the following associative array:

[
   'animal' => 'sheep',
   'spirit_animal' => 'bear',
   'primal_animal' => 'sloth'
]

Parameters

array $mapEntriesList

a list of map entries

Throws

\UnexpectedValueException

if any map entries in the list are invalid

Returns

array —

an associative array of the entries

fromAssociativeArray()

fromAssociativeArray(array  $mapEntriesAssociativeArray,string  $mapEntryClassName): array

Transforms the specified associative array to a list of entries of the specified type. The type is expected to be a `[Key]_[Value]MapEntry` that contains a key and a value.

For example, if the associative array of map entries were:

[
   'animal' => 'sheep',
   'spirit_animal' => 'bear',
   'primal_animal' => 'sloth'
]

Then this method would return the following list of map entries if String_StringMapEntry was specified as the map entry class type:

[
  (String_StringMapEntry: key => 'animal', value => 'sheep'),
  (String_StringMapEntry: key => 'spirit_animal', value => 'bear'),
  (String_StringMapEntry: key => 'primal_animal', value => 'sloth')
]

Parameters

array $mapEntriesAssociativeArray

an associative array of map entries

string $mapEntryClassName

the fully qualified class name of the map entry type to use

Throws

\UnexpectedValueException

if the map entry class is invalid

Returns

array —

a list of map entries built from the key-value pairs in the associative array

__construct()

__construct()