SetPostalAddressTrait
Injects and normalizes the postal address of an entity from flat property expressions.
The consumer class must declare an address property. Flat keys, e.g. addressEmail
or streetAddress, are routed to the nested PostalAddress
instance, created on demand.
Tags
Table of Contents
Methods
- normalizePostalAddress() : mixed
- Normalize a PostalAddress definition and search if the streetAddress expression contains a ';' separator to extract properties from the specific field.
- setPostalAddressProperties() : bool
- Set the PostalAddress properties.
- setPostalAddressProperty() : bool
- Internal method to inject custom properties in the PostalAddress property of the place.
Methods
normalizePostalAddress()
Normalize a PostalAddress definition and search if the streetAddress expression contains a ';' separator to extract properties from the specific field.
public
static normalizePostalAddress(mixed $definition[, string $separator = ';' ]) : mixed
Parameters
- $definition : mixed
-
The definition to normalize.
- $separator : string = ';'
-
The separator to explode the postal address expression (default ';'). An empty separator splits nothing and leaves the definition untouched —
explode()would raise aValueErroron it.
setPostalAddressProperties()
Set the PostalAddress properties.
public
setPostalAddressProperties(string $property, mixed $value) : bool
Parameters
- $property : string
- $value : mixed
Return values
boolsetPostalAddressProperty()
Internal method to inject custom properties in the PostalAddress property of the place.
public
setPostalAddressProperty(string $name, mixed $value) : bool
Parameters
- $name : string
- $value : mixed