Oihana PHP System

hydrateBusinessDocument.php

Table of Contents

Functions

hydrateBusinessDocument()  : mixed
Hydrate an array definition with the BusinessDocument class, or one of its subclasses ({@see \xyz\oihana\schema\business\documents\Quote}, {@see \xyz\oihana\schema\business\documents\PurchaseOrder}, {@see Invoice}, {@see \xyz\oihana\schema\business\documents\CreditNote}, {@see \xyz\oihana\schema\business\documents\DebitNote}, {@see \xyz\oihana\schema\business\documents\DeliveryNote}, {@see \xyz\oihana\schema\business\documents\GoodsReceiptConfirmation}, {@see \xyz\oihana\schema\business\documents\Receipt}, {@see \xyz\oihana\schema\business\documents\RemittanceAdvice}, {@see \xyz\oihana\schema\business\documents\Statement}).

Functions

hydrateBusinessDocument()

Hydrate an array definition with the BusinessDocument class, or one of its subclasses ({@see \xyz\oihana\schema\business\documents\Quote}, {@see \xyz\oihana\schema\business\documents\PurchaseOrder}, {@see Invoice}, {@see \xyz\oihana\schema\business\documents\CreditNote}, {@see \xyz\oihana\schema\business\documents\DebitNote}, {@see \xyz\oihana\schema\business\documents\DeliveryNote}, {@see \xyz\oihana\schema\business\documents\GoodsReceiptConfirmation}, {@see \xyz\oihana\schema\business\documents\Receipt}, {@see \xyz\oihana\schema\business\documents\RemittanceAdvice}, {@see \xyz\oihana\schema\business\documents\Statement}).

hydrateBusinessDocument([mixed $init = null ][, string $class = BusinessDocument::class ]) : mixed

Handles both a single document array and an array of documents. The document itself is built through Reflection::hydrate(), which honors every #[HydrateAs]/#[HydrateWith] attribute declared across the hierarchy (adjustments, taxes, totals, documentLines...).

customer, seller and author are the exception, on every document class : their Organization|Person union cannot be resolved from the property type alone — reflection always picks Organization, even for a Person payload — so they are re-resolved from the raw payload through hydrateOrganizationOrPerson(). On an Invoice, broker and provider carry the same union and get the same treatment.

The document's ParcelDelivery carries the same union one level down, on its own provider — the carrier. Reflection builds the delivery through #[HydrateAs], so nothing inside it was ever re-resolved : orderDelivery.provider is therefore given the same treatment from the raw payload, once the delivery itself has been hydrated.

Parameters
$init : mixed = null

Single document data or array of document data.

$class : string = BusinessDocument::class

The BusinessDocument subclass to hydrate into. Defaults to BusinessDocument itself.

Tags
throws
HydrationException
ReflectionException
example
hydrateBusinessDocument( $raw ) ;                          // BusinessDocument
hydrateBusinessDocument( $raw , Invoice::class ) ;          // Invoice — also resolves broker/provider
hydrateBusinessDocument( $raw , Quote::class ) ;            // Quote
On this page

Search results