termClassOf.php
Table of Contents
Functions
- termClassOf() : DefinedTerm>
- Answer the class one term property is hydrated into.
Functions
termClassOf()
Answer the class one term property is hydrated into.
termClassOf(DefinedTerm>|array<string, DefinedTerm>|array<string, DefinedTerm>>> $termClass, string $property) : DefinedTerm>
A hydrator that resolves several vocabularies takes one $termClass parameter rather
than one per property, and reads it through this helper. The parameter accepts two forms,
and the short one is the common case :
- a class name — every term of the entity is hydrated into it ;
- a map —
[ Prop::DEFAULT => …, '<property>' => … ], where each key names a property and Prop::DEFAULT covers everything left unnamed.
The two forms are the same statement at two levels of detail, so a caller only writes a map the day one family stops answering what the others answer. Anything a map does not name — no key for the property, no Prop::DEFAULT — falls back to ThesaurusTerm, the class the house families serve.
🔑 A nested branch is not a class, and is never answered as one. A map may carry a sub-map
under a property that holds a whole entity rather than a term — report, for instance,
whose own terms belong to their own families. Such an entry is not a class name, so it is
never returned here : the hydrator that owns that property reads the branch itself and
hands it down. This helper answers classes, and only classes.
⚠️ A map is keyed by property, not by family. Two entities of one hierarchy may declare
the same property name over two different families — a meeting's tags and its report's
tags are not the same vocabulary. One flat map cannot tell them apart, which is exactly
what the nested branch is for : the inner entity inherits the outer map until the caller
gives it one of its own.
Parameters
- $termClass : DefinedTerm>|array<string, DefinedTerm>|array<string, DefinedTerm>>>
-
A class name, or a map of property name to class name.
- $property : string
-
The property whose class is asked for.