Oihana PHP System

SiteTrait uses trait:short, trait:short, trait:short, trait:short

Groups the ingestion behaviors shared by all the site flavored places : additional properties, geo coordinates, postal address and contact points.

The __set hook routes any unknown property expression to the matching handler, so a flat dataset row can hydrate a site without manual mapping.

Tags
author

Marc Alcaraz (eKameleon)

since
1.3.0

Table of Contents

Methods

__set()  : void
normalizePostalAddress()  : mixed
Normalize a PostalAddress definition and search if the streetAddress expression contains a ';' separator to extract properties from the specific field.
setAdditionalProperties()  : bool
Set a new optional additional properties of the place.
setGeoCoordinatesProperties()  : bool
Set the GeoCoordinates properties.
setGeoCoordinatesProperty()  : bool
Internal method to inject custom properties in the PostalAddress property of the place.
setPostalAddressProperties()  : bool
Set the PostalAddress properties.
setPostalAddressProperty()  : bool
Internal method to inject custom properties in the PostalAddress property of the place.
contactPointList()  : array<string|int, mixed>
The contact points as a list, whatever shape the property holds.
findContactPointByType()  : ContactPoint|null
Find a specific ContactPoint reference by type.
isValidPhoneNumber()  : bool
Validate a phone number expression (basic check, any country).
setAdditionalProperty()  : void
Internal method to inject custom properties in the PostalAddress property of the place.
setContactPointProperty()  : bool
Internal method to inject custom properties in the PostalAddress property of the place.

Methods

__set()

public __set(string $property, mixed $value) : void
Parameters
$property : string

Property name.

$value : mixed

Value of the property.

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 a ValueError on it.

setAdditionalProperties()

Set a new optional additional properties of the place.

public setAdditionalProperties(string $property, mixed $value) : bool
Parameters
$property : string

Property name.

$value : mixed

Value of the property.

Return values
bool —

True if the property was handled, false otherwise

setGeoCoordinatesProperties()

Set the GeoCoordinates properties.

public setGeoCoordinatesProperties(string $property, mixed $value) : bool
Parameters
$property : string

The property to inject.

$value : mixed

The value of the property.

Return values
bool

setGeoCoordinatesProperty()

Internal method to inject custom properties in the PostalAddress property of the place.

public setGeoCoordinatesProperty(string $name, mixed $value) : bool
Parameters
$name : string

The name of the property to transform.

$value : mixed

The value of the property.

Return values
bool

setPostalAddressProperties()

Set the PostalAddress properties.

public setPostalAddressProperties(string $property, mixed $value) : bool
Parameters
$property : string
$value : mixed
Return values
bool

setPostalAddressProperty()

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
Return values
bool

contactPointList()

The contact points as a list, whatever shape the property holds.

protected contactPointList() : array<string|int, mixed>

contactPoint is declared as null|ContactPoint|array|string wherever this trait is composed, but the code around it only ever makes sense on a list. A lone ContactPoint and an unresolved string reference are therefore wrapped rather than discarded — nothing is lost, and the caller can iterate and append without checking first.

Return values
array<string|int, mixed> —

The contact points, always a list.

findContactPointByType()

Find a specific ContactPoint reference by type.

protected findContactPointByType(string|null $type) : ContactPoint|null

Entries that are not hydrated ContactPoint instances — the raw arrays a base read hands back, or an unresolved reference — are skipped rather than dereferenced, so only a real instance is ever returned.

Parameters
$type : string|null

The type of the resource to find.

Return values
ContactPoint|null

isValidPhoneNumber()

Validate a phone number expression (basic check, any country).

protected isValidPhoneNumber(string $phone[, string|null $defaultRegion = 'FR' ]) : bool
Parameters
$phone : string

The phone number to validate.

$defaultRegion : string|null = 'FR'

region that we are expecting the number to be from. This is only used if the number being parsed is not written in international format. The country_code for the number in this case would be stored as that of the default region supplied. If the number is guaranteed to start with a '+' followed by the country calling code, then "ZZ" or null can be supplied.

Return values
bool —

True if valid, false otherwise.

setAdditionalProperty()

Internal method to inject custom properties in the PostalAddress property of the place.

protected setAdditionalProperty(array<string|int, mixed> $init) : void
Parameters
$init : array<string|int, mixed>
Tags
throws
ReflectionException

setContactPointProperty()

Internal method to inject custom properties in the PostalAddress property of the place.

protected setContactPointProperty(string $name, mixed $value) : bool
Parameters
$name : string

The name of the property to transform.

$value : mixed

The value of the property.

Return values
bool
On this page

Search results