TypeDefinition
in package
implements
IteratorAggregate, Countable
Defines a data type comprising multiple fields
Tags
Table of Contents
Interfaces
- IteratorAggregate
- Countable
Properties
- $fieldCount : int
- $fieldDefFactory : FieldDefinitionFactory
- $fieldDefs : array<string|int, int>
- $fieldNameMap : array<string|int, int>
- $lastField : FieldDefinition
- $toStringFunction : callable
Methods
- __construct() : mixed
- Constructor
- count() : int
- Get the number of fields (Countable interface)
- getFieldDefinition() : FieldDefinition
- Get the field definition indicated by the supplied index
- getFieldIndexByName() : int
- Get the field index indicated by the supplied name
- getIterator() : Iterator
- Retrieve an iterator (IteratorAggregate interface)
- getToStringFunction() : callable|null
- Get the __toString() implementation
- setToStringFunction() : mixed
- Set the __toString() implementation
- registerField() : mixed
- Register a field from the type definition
Properties
$fieldCount
private
int
$fieldCount
Number of fields in the type
$fieldDefFactory
private
FieldDefinitionFactory
$fieldDefFactory
Creates FieldDefinition objects
$fieldDefs
private
array<string|int, int>
$fieldDefs
= []
Map of field indexes to type identifiers
$fieldNameMap
private
array<string|int, int>
$fieldNameMap
= []
Map of field names to indexes
$lastField
private
FieldDefinition
$lastField
The last field defined by the type
$toStringFunction
private
callable
$toStringFunction
Custom implementation for __toString() handling
Methods
__construct()
Constructor
public
__construct(FieldDefinitionFactory $fieldDefFactory, array<string|int, mixed> $definition) : mixed
Parameters
- $fieldDefFactory : FieldDefinitionFactory
- $definition : array<string|int, mixed>
-
Structural definition of the fields
Tags
count()
Get the number of fields (Countable interface)
public
count() : int
Return values
intgetFieldDefinition()
Get the field definition indicated by the supplied index
public
getFieldDefinition(int $index) : FieldDefinition
Parameters
- $index : int
Tags
Return values
FieldDefinitiongetFieldIndexByName()
Get the field index indicated by the supplied name
public
getFieldIndexByName(string $name) : int
Parameters
- $name : string
Tags
Return values
intgetIterator()
Retrieve an iterator (IteratorAggregate interface)
public
getIterator() : Iterator
Return values
IteratorgetToStringFunction()
Get the __toString() implementation
public
getToStringFunction() : callable|null
Return values
callable|nullsetToStringFunction()
Set the __toString() implementation
public
setToStringFunction(callable $function) : mixed
Parameters
- $function : callable
registerField()
Register a field from the type definition
private
registerField(int $index, string $name, int $type) : mixed
Parameters
- $index : int
- $name : string
- $type : int