Factory
in package
Factory class for creating Data Transfer Objects (DTOs) from YAML configuration files or arrays.
This factory can read YAML files containing DTO definitions OR accept arrays with DTO definitions, and creates corresponding Dto objects with properties, validation rules, and nested structures.
Table of Contents
Properties
Methods
- __construct() : mixed
- create() : Dto
- getSource() : string|array<string|int, mixed>
- createArray() : Collection
- createDto() : Dto
- createProperty() : Property
- isAbsolutePath() : bool
- Check if a path is absolute
- loadReferencedDto() : Dto
- Load a referenced DTO from a file path, with caching
- resolveReferencePath() : string
- Resolve a reference path relative to the current source
- setLengthRange() : Property
- setValueRange() : mixed
Properties
$dtoCache
private
static array<string|int, mixed>
$dtoCache
= []
$source
private
string|array<string|int, mixed>
$source
Methods
__construct()
public
__construct(string|array<string|int, mixed> $source) : mixed
Parameters
- $source : string|array<string|int, mixed>
-
YAML file path or array of DTO properties
create()
public
create() : Dto
Tags
Return values
DtogetSource()
public
getSource() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>createArray()
protected
createArray(string $name, array<string|int, mixed> $data) : Collection
Parameters
- $name : string
- $data : array<string|int, mixed>
Tags
Return values
CollectioncreateDto()
protected
createDto(string $name, array<string|int, mixed> $data) : Dto
Parameters
- $name : string
- $data : array<string|int, mixed>
Tags
Return values
DtocreateProperty()
protected
createProperty(int|string $name, array<string|int, mixed> $propertyData, Dto $parent) : Property
Parameters
- $name : int|string
- $propertyData : array<string|int, mixed>
- $parent : Dto
Tags
Return values
PropertyisAbsolutePath()
Check if a path is absolute
protected
isAbsolutePath(string $path) : bool
Parameters
- $path : string
Return values
boolloadReferencedDto()
Load a referenced DTO from a file path, with caching
protected
loadReferencedDto(string $ref) : Dto
Parameters
- $ref : string
-
The reference path to the DTO YAML file
Tags
Return values
DtoresolveReferencePath()
Resolve a reference path relative to the current source
protected
resolveReferencePath(string $ref) : string
Parameters
- $ref : string
Return values
stringsetLengthRange()
protected
setLengthRange(array<string|int, mixed> $propertyData, Property $property) : Property
Parameters
- $propertyData : array<string|int, mixed>
- $property : Property
Return values
PropertysetValueRange()
protected
setValueRange(array<string|int, mixed> $propertyData, Property $property) : mixed
Parameters
- $propertyData : array<string|int, mixed>
- $property : Property