Documentation

RecordCollection
in package
implements IteratorAggregate, Countable

Collection of Record objects

Tags
category

LibDNS

author

Chris Wright https://github.com/DaveRandom

Table of Contents

Interfaces

IteratorAggregate
Countable

Properties

$length  : int
$nameMap  : array<string|int, array<string|int, Record>>
$records  : array<string|int, Record>
$type  : int

Methods

__construct()  : mixed
Constructor
add()  : mixed
Add a record to the collection
clear()  : mixed
Remove all records from the collection
clearRecordsByName()  : int
Remove all records in the collection that refer to the specified name
contains()  : bool
Test whether the collection contains a specific record
count()  : int
Get the number of records in the collection (Countable interface)
getIterator()  : Iterator
Retrieve an iterator (IteratorAggregate interface)
getNames()  : array<string|int, string>
Get a list of all names referenced by records in the collection
getRecordByIndex()  : Record
Get a record from the collection by index
getRecordsByName()  : array<string|int, Record>
Get all records in the collection that refer to the specified name
getType()  : int
Get whether the collection holds question or resource records
remove()  : mixed
Remove a record from the collection
addToNameMap()  : mixed
Add a record to the correct bucket in the name map
removeFromNameMap()  : mixed
Remove a record from the name map

Properties

$nameMap

private array<string|int, array<string|int, Record>> $nameMap = []

Map of Records in the collection grouped by record name

$type

private int $type

Whether the collection holds question or resource records

Methods

__construct()

Constructor

public __construct(int $type) : mixed
Parameters
$type : int

Can be indicated using the RecordTypes enum

Tags
throws
InvalidArgumentException

When the specified record type is invalid

add()

Add a record to the collection

public add(Record $record) : mixed
Parameters
$record : Record

The record to add

Tags
throws
InvalidArgumentException

When the wrong record type is supplied

clearRecordsByName()

Remove all records in the collection that refer to the specified name

public clearRecordsByName(string $name) : int
Parameters
$name : string

The name to match records against

Return values
int

The number of records removed

contains()

Test whether the collection contains a specific record

public contains(Record $record[, bool $sameInstance = false ]) : bool
Parameters
$record : Record

The record to search for

$sameInstance : bool = false

Whether to perform strict comparisons in search

Return values
bool

count()

Get the number of records in the collection (Countable interface)

public count() : int
Return values
int

getIterator()

Retrieve an iterator (IteratorAggregate interface)

public getIterator() : Iterator
Return values
Iterator

getNames()

Get a list of all names referenced by records in the collection

public getNames() : array<string|int, string>
Return values
array<string|int, string>

getRecordByIndex()

Get a record from the collection by index

public getRecordByIndex(int $index) : Record
Parameters
$index : int

Record index

Tags
throws
OutOfBoundsException

When the supplied index does not refer to a valid record

Return values
Record

getRecordsByName()

Get all records in the collection that refer to the specified name

public getRecordsByName(string $name) : array<string|int, Record>
Parameters
$name : string

The name to match records against

Return values
array<string|int, Record>

getType()

Get whether the collection holds question or resource records

public getType() : int
Return values
int

remove()

Remove a record from the collection

public remove(Record $record) : mixed
Parameters
$record : Record

The record to remove

addToNameMap()

Add a record to the correct bucket in the name map

private addToNameMap(Record $record) : mixed
Parameters
$record : Record

The record to add

removeFromNameMap()

Remove a record from the name map

private removeFromNameMap(Record $record) : mixed
Parameters
$record : Record

The record to remove


        
On this page

Search results