RecordCollection
in package
implements
IteratorAggregate, Countable
Collection of Record objects
Tags
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
$length
private
int
$length
= 0
Number of Records in the collection
$nameMap
private
array<string|int, array<string|int, Record>>
$nameMap
= []
Map of Records in the collection grouped by record name
$records
private
array<string|int, Record>
$records
= []
List of records held in the collection
$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
add()
Add a record to the collection
public
add(Record $record) : mixed
Parameters
- $record : Record
-
The record to add
Tags
clear()
Remove all records from the collection
public
clear() : mixed
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
boolcount()
Get the number of records in the collection (Countable interface)
public
count() : int
Return values
intgetIterator()
Retrieve an iterator (IteratorAggregate interface)
public
getIterator() : Iterator
Return values
IteratorgetNames()
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
Return values
RecordgetRecordsByName()
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
intremove()
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