Documentation

TypeDefinition
in package
implements IteratorAggregate, Countable

Defines a data type comprising multiple fields

Tags
category

LibDNS

author

Chris Wright https://github.com/DaveRandom

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

$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

$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
throws
InvalidArgumentException

When the type definition is invalid

count()

Get the number of fields (Countable interface)

public count() : int
Return values
int

getFieldDefinition()

Get the field definition indicated by the supplied index

public getFieldDefinition(int $index) : FieldDefinition
Parameters
$index : int
Tags
throws
OutOfBoundsException

When the supplied index does not refer to a valid field

Return values
FieldDefinition

getFieldIndexByName()

Get the field index indicated by the supplied name

public getFieldIndexByName(string $name) : int
Parameters
$name : string
Tags
throws
OutOfBoundsException

When the supplied name does not refer to a valid field

Return values
int

getIterator()

Retrieve an iterator (IteratorAggregate interface)

public getIterator() : Iterator
Return values
Iterator

getToStringFunction()

Get the __toString() implementation

public getToStringFunction() : callable|null
Return values
callable|null

setToStringFunction()

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
Tags
throws
InvalidArgumentException

When the field definition is invalid


        
On this page

Search results