hydrateCustomer.php
Table of Contents
Functions
- hydrateCustomer() : mixed
- Hydrate an array definition with the Customer class.
Functions
hydrateCustomer()
Hydrate an array definition with the Customer class.
hydrateCustomer([mixed $init = null ]) : mixed
Handles both a single customer array and an array of customers, and hydrates the
nested contactPoint and address references so the resolved customer carries typed
values rather than raw arrays.
Each nested reference is hydrated only when the raw value is an array — when there is
something to hydrate. The helper's answer is then written as is, null included : an
array that resolves to nothing (an empty list, a list of unhydratable entries) becomes
null, never a leftover raw array, so the customer answers the same thing as the
nested helper called on its own. Anything that is not an array — an unresolved string
reference, an already typed instance — is left untouched.
🔑 A bare reference survives inside a list, exactly as it does on its own : a list of unresolved handles comes back as it stands, and only an entry that was an array and resolved to nothing is dropped. The keys stay gap-free — a filtered list left with holes serializes as a JSON object, and a consumer walking the value gets something it cannot walk.
Parameters
- $init : mixed = null
-
Single customer data or array of customer data.