Oihana PHP System

hydrateVisitReport.php

Table of Contents

Functions

hydrateVisitReport()  : mixed
Hydrate an array definition with the VisitReport class.

Functions

hydrateVisitReport()

Hydrate an array definition with the VisitReport class.

hydrateVisitReport([mixed $init = null ][, DefinedTerm>|array<string, DefinedTerm>|array<string, DefinedTerm>>> $termClass = ThesaurusTerm::class ]) : mixed

Handles both a single report array and an array of reports.

🔑 What every report carries is resolved by hydrateMeetingReport() — the promises, the qualifiers, what was covered, who wrote it — and this helper asks it for a VisitReport rather than copying its body. What is left here is what only a visit carries :

  • attendee — the people actually met, as CustomerEmployee, one or several. The parent leaves the union wide on purpose : who sits at a table depends on the kind of meeting, and a visit is the family that knows ;
  • mood and outcome — one term each, how it felt and what it produced.

🔑 The vocabularies are read as the class their family serves, in the two forms termClassOf() reads — one class for every property, or a map naming them one by one :

hydrateVisitReport( $raw ) ;                       // the house term, everywhere
hydrateVisitReport( $raw , DefinedTerm::class ) ;  // one named class, everywhere
hydrateVisitReport( $raw , [ Prop::DEFAULT => ThesaurusTerm::class , VisitReport::MOOD => MoodTerm::class ] ) ;

🔑 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 report data or array of report data.

$termClass : DefinedTerm>|array<string, DefinedTerm>|array<string, DefinedTerm>>> = ThesaurusTerm::class

The class the term properties are hydrated into, or a map naming them one by one. A map may carry entries this helper does not read — a report hydrated from a meeting receives the meeting's map as it stands, branches included. See termClassOf().

Tags
throws
ReflectionException
example
$report = hydrateVisitReport
([
    'mood'     => [ 'id' => 'SATISFIED' , 'name' => 'Satisfied' ] ,
    'attendee' => [ [ 'name' => 'Jane Doe' , 'jobTitle' => [ 'id' => 'BUYER' ] ] ] ,
    'followUp' => [ [ 'followUpType' => [ 'id' => 'CALL_BACK' ] ] ] ,
    'text'     => 'Everything the boxes cannot hold.' ,
]) ;

$report->attendee[ 0 ] instanceof CustomerEmployee ; // true
$report->followUp[ 0 ] instanceof FollowUp         ; // true
$report->mood          instanceof ThesaurusTerm    ; // true
On this page

Search results