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