hydrate
Table of Contents
Functions
- hydrateAdditionalProperty() : array<string|int, PropertyValue>|mixed|null
- Hydrate an array of PropertyValue objects.
- hydrateContactPoint() : array<string|int, ContactPoint>|mixed|null
- Hydrate an array of ContactPoint objects.
- hydrateDefinedTerm() : mixed
- Hydrate an array definition with the DefinedTerm class.
- hydrateGeoCoordinates() : mixed
- Hydrate an array definition with the GeoCoordinates class.
- hydrateOfferPurchase() : OfferForPurchase|null
- Hydrate an OfferForPurchase from an array or instance.
- hydrateOrganizationOrPerson() : mixed
- Hydrate an array definition into an Organization or a Person.
- hydratePostalAddress() : mixed
- Hydrate an array definition with the PostalAddress class.
Functions
hydrateAdditionalProperty()
Hydrate an array of PropertyValue objects.
hydrateAdditionalProperty([mixed $properties = null ]) : array<string|int, PropertyValue>|mixed|null
Anything that is not an array is handed back untouched — a lone
PropertyValue is a legal shape of the additionalProperty property,
and this helper is not the place to reject it. An array that is not an
indexed, non-empty list yields null, so a caller can tell "nothing to
hydrate" from a result.
Parameters
- $properties : mixed = null
-
An indexed array of PropertyValue definitions, or any value to pass through.
Tags
Return values
array<string|int, PropertyValue>|mixed|nullhydrateContactPoint()
Hydrate an array of ContactPoint objects.
hydrateContactPoint([mixed $properties = null ]) : array<string|int, ContactPoint>|mixed|null
Anything that is not an array is handed back untouched — a lone
ContactPoint or an unresolved string reference are legal shapes of the
contactPoint property, and this helper is not the place to reject them. An
array that is not an indexed, non-empty list yields null, so a caller can
tell "nothing to hydrate" from a result.
Parameters
- $properties : mixed = null
-
An indexed array of ContactPoint definitions, or any value to pass through.
Tags
Return values
array<string|int, ContactPoint>|mixed|nullhydrateDefinedTerm()
Hydrate an array definition with the DefinedTerm class.
hydrateDefinedTerm([mixed $init = null ][, DefinedTerm> $class = DefinedTerm::class ]) : mixed
Handles both single DefinedTerm array and array of DefinedTerm.
Parameters
- $init : mixed = null
-
Single DefinedTerm data or array of DefinedTerm data.
- $class : DefinedTerm> = DefinedTerm::class
-
The class to hydrate into. A subclass lets an enriched term keep the properties DefinedTerm does not declare.
Tags
hydrateGeoCoordinates()
Hydrate an array definition with the GeoCoordinates class.
hydrateGeoCoordinates([mixed $init = null ]) : mixed
Handles both single GeoCoordinates array and array of GeoCoordinates.
Parameters
- $init : mixed = null
-
Single GeoCoordinates data or array of GeoCoordinates data
Tags
hydrateOfferPurchase()
Hydrate an OfferForPurchase from an array or instance.
hydrateOfferPurchase(mixed $data) : OfferForPurchase|null
Parameters
- $data : mixed
Tags
Return values
OfferForPurchase|nullhydrateOrganizationOrPerson()
Hydrate an array definition into an Organization or a Person.
hydrateOrganizationOrPerson([mixed $init = null ][, string $organizationClass = Organization::class ][, string $personClass = Person::class ]) : mixed
Organization|Person is a common Schema.org union (e.g. Order::$customer,
Order::$seller, Invoice::$broker/$provider, Event::$funder...) that
Reflection::hydrate() cannot resolve from the property type alone : the
declared union always resolves to its first class member, so a Person payload
silently comes out as an (empty-ish) Organization. This helper reads the
payload's JSON-LD @type instead : Person gives a Person (or
$personClass), anything else — Organization itself, or one of its many
subtypes (Corporation, LocalBusiness, GovernmentOrganization...) — gives
an Organization (or $organizationClass), which stays the safe default
when @type is absent or unrecognized.
$organizationClass/$personClass let a caller pin the target to a business
subtype instead of the plain Schema.org class — e.g.
xyz\oihana\schema\organizations\Customer (extends Organization) or
xyz\oihana\schema\people\CustomerEmployee (extends Person) — as long as
each stays a subclass of the type it replaces, so the property's declared
union type still holds.
Handles both a single definition and an indexed list of definitions.
Parameters
- $init : mixed = null
-
Single Organization/Person data, a list of such data, or any other value.
- $organizationClass : string = Organization::class
-
The class hydrated when the payload is not a Person. Must extend Organization.
- $personClass : string = Person::class
-
The class hydrated when the payload's
@typesays Person. Must extend Person.
Tags
hydratePostalAddress()
Hydrate an array definition with the PostalAddress class.
hydratePostalAddress([mixed $init = null ]) : mixed
Handles both single PostalAddress array and array of PostalAddress.
Parameters
- $init : mixed = null
-
Single PostalAddress data or array of PostalAddress data