Oihana PHP System

SchemaResolver

Read onlyYes
FinalYes

Resolves a schema class name from a target object or array.

The resolver inspects a given target (object or array), extracts a type value using the provided key, and maps it to a schema class name.

If the target is not an object or array, or if the resolved value is not a non-empty string, null is returned.

Typical usage includes dynamic schema resolution in data mappers, document models, or hydration pipelines.

Table of Contents

Properties

$default  : string|null
$key  : string
$map  : array<string|int, mixed>

Methods

__construct()  : mixed
Creates a new SchemaResolver instance.
__invoke()  : string|null
Resolves the schema class name for the given target.

Properties

Methods

__construct()

Creates a new SchemaResolver instance.

public __construct(string $key, array<string|int, mixed> $map[, string|null $default = null ]) : mixed
Parameters
$key : string

Key used to extract the schema type from the target (e.g. Prop::ADDITIONAL_TYPE).

$map : array<string|int, mixed>

Associative map of schema types to class names. Keys are schema type identifiers, values must be fully-qualified class names.

$default : string|null = null

Default schema class name to use when no mapping matches. Must be a non-empty string or null.

__invoke()

Resolves the schema class name for the given target.

public __invoke(mixed $target) : string|null
Parameters
$target : mixed

Object or array containing a schema type value.

Return values
string|null

Fully-qualified schema class name, or null if the target is not resolvable or no valid mapping exists.


        
On this page

Search results