XmlNamedNodeList
extends ReadonlyCollection
in package
XmlNamedNodeList
This class represents a list of nodes.
Table of Contents
Properties
- $document : DOMDocument
- $data : mixed
- Collection internal data
- $_document : DOMDocument
- The document.
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Getter
- __set() : void
- Magic method to set the value of a property by its name.
- Add() : mixed
- Adds a key-value pair to the collection.
- Append() : void
- Appends data from another source to the collection.
- Clean() : void
- Clears empty values.
- Clear() : void
- Clears the collection by removing all key-value pairs.
- Contains() : bool
- Checks if the specified item exists in the data array.
- Count() : int
- Returns the number of elements in the collection.
- Delete() : bool
- Removes the key-value pair with the specified key from the collection.
- DeleteAt() : bool
- Removes the key-value pair at the specified index from the collection.
- Exists() : bool
- Checks if the key exists
- Extract() : Collection
- Extracts data from a specified page using the given page size.
- Filter() : Collection
- Filters the collection data based on the provided closure.
- First() : mixed|null
- Retrieves the first element from the collection.
- FromString() : Collection
- Creates a collection from a string representation.
- getIterator() : XmlNamedNodeListIterator
- Returns an iterator for iteration using foreach.
- IndexOf() : mixed|null
- Searches for the specified item in the data array and returns its index.
- Insert() : mixed
- Inserts a key-value pair at the specified index in the data array.
- Item() : XmlNode|null
- Returns the node by key.
- ItemAt() : XmlNode
- Returns the node by index.
- jsonSerialize() : mixed
- Serializes the object to a value that can be natively serialized by json_encode().
- Key() : string|null
- Retrieves the key at the specified index in the data array.
- Last() : mixed|null
- Retrieves the last element from the collection.
- offsetExists() : bool
- Checks whether an offset exists.
- offsetGet() : mixed|null
- Retrieves the element from the collection at the specified index.
- offsetGet() : XmlNode
- offsetSet() : void
- Sets the value at the specified offset in the data array.
- offsetUnset() : void
- Unsets the value at the specified index.
- ToArray() : array<string|int, mixed>
- Converts the collection data to an array.
- ToString() : string
- Converts the collection data to a string representation.
Properties
$document read-only
public
DOMDocument
$document
The document.
$data
Collection internal data
protected
mixed
$data
= null
$_document
The document.
private
DOMDocument
$_document
Methods
__construct()
Constructor
public
__construct(DOMNodeList $nodelist, DOMDocument $dom) : mixed
Parameters
- $nodelist : DOMNodeList
-
The node list.
- $dom : DOMDocument
-
The document.
__get()
Getter
public
__get(string $property) : mixed
Parameters
- $property : string
-
The property.
__set()
Magic method to set the value of a property by its name.
public
__set(string $key, mixed $value) : void
Parameters
- $key : string
-
The name of the property to set.
- $value : mixed
-
The value to assign to the property.
Add()
Adds a key-value pair to the collection.
public
Add(string $key, mixed $value) : mixed
Parameters
- $key : string
-
The key to add.
- $value : mixed
-
The value associated with the key.
Tags
Return values
mixed —The updated collection data.
Append()
Appends data from another source to the collection.
public
Append(mixed $from) : void
Parameters
- $from : mixed
-
The data source to append.
Tags
Clean()
Clears empty values.
public
Clean() : void
Clear()
Clears the collection by removing all key-value pairs.
public
Clear() : void
Tags
Contains()
Checks if the specified item exists in the data array.
public
Contains(mixed $item) : bool
Parameters
- $item : mixed
-
The item to search for.
Tags
Return values
bool —True if the item is found, false otherwise.
Count()
Returns the number of elements in the collection.
public
Count() : int
Tags
Return values
int —The count of elements in the collection.
Delete()
Removes the key-value pair with the specified key from the collection.
public
Delete(string $key) : bool
Parameters
- $key : string
-
The key to delete.
Tags
Return values
bool —True if the key was successfully deleted, false otherwise.
DeleteAt()
Removes the key-value pair at the specified index from the collection.
public
DeleteAt(int $index) : bool
Parameters
- $index : int
-
The index of the key-value pair to delete.
Tags
Return values
bool —True if the key-value pair was successfully deleted, false otherwise.
Exists()
Checks if the key exists
public
Exists(string $key) : bool
Parameters
- $key : string
Tags
Return values
boolExtract()
Extracts data from a specified page using the given page size.
public
Extract(mixed $page, mixed $pagesize) : Collection
Parameters
- $page : mixed
-
The page to extract data from.
- $pagesize : mixed
-
The size of the page.
Tags
Return values
Collection —The extracted data collection.
Filter()
Filters the collection data based on the provided closure.
public
Filter(Closure $closure) : Collection
Parameters
- $closure : Closure
-
The closure used for filtering.
Tags
Return values
Collection —The filtered collection.
First()
Retrieves the first element from the collection.
public
First() : mixed|null
Tags
Return values
mixed|null —The first element if the collection is not empty, or null if empty.
FromString()
Creates a collection from a string representation.
public
static FromString(string $string[, array<string|int, mixed>|null $splitters = null ]) : Collection
Parameters
- $string : string
-
The string containing data to initialize the collection.
- $splitters : array<string|int, mixed>|null = null
-
Optional array of splitters to parse the string data.
Tags
Return values
Collection —The initialized collection.
getIterator()
Returns an iterator for iteration using foreach.
public
getIterator() : XmlNamedNodeListIterator
Return values
XmlNamedNodeListIteratorIndexOf()
Searches for the specified item in the data array and returns its index.
public
IndexOf(mixed $item) : mixed|null
Parameters
- $item : mixed
-
The item to search for.
Tags
Return values
mixed|null —The index of the item if found, or null if not found.
Insert()
Inserts a key-value pair at the specified index in the data array.
public
Insert(mixed $index, mixed $key, mixed $value) : mixed
Parameters
- $index : mixed
-
The index where the key-value pair should be inserted.
- $key : mixed
-
The key to insert.
- $value : mixed
-
The value associated with the key.
Tags
Return values
mixed —The updated collection data.
Item()
Returns the node by key.
public
Item(string $key) : XmlNode|null
Parameters
- $key : string
-
The key.
Return values
XmlNode|null —The node, or null if not found.
ItemAt()
Returns the node by index.
public
ItemAt(int $index) : XmlNode
Parameters
- $index : int
-
The index.
Return values
XmlNode —The node.
jsonSerialize()
Serializes the object to a value that can be natively serialized by json_encode().
public
jsonSerialize() : mixed
Tags
Return values
mixed —The serialized data, which can be of any type other than a resource.
Key()
Retrieves the key at the specified index in the data array.
public
Key(int $index) : string|null
Parameters
- $index : int
-
The index of the key to retrieve.
Tags
Return values
string|null —The key if found, or null if the index is out of bounds.
Last()
Retrieves the last element from the collection.
public
Last() : mixed|null
Tags
Return values
mixed|null —The last element if the collection is not empty, or null if empty.
offsetExists()
Checks whether an offset exists.
public
offsetExists(mixed $offset) : bool
This method is executed when using isset()
or empty()
on objects implementing the ArrayAccess
interface.
Parameters
- $offset : mixed
-
The offset (index) to check for existence.
Return values
bool —Returns true
if the offset exists, and false
otherwise.
offsetGet()
Retrieves the element from the collection at the specified index.
public
offsetGet(mixed $offset) : mixed|null
Parameters
- $offset : mixed
Return values
mixed|null —The collection element or null if the element is not found.
offsetGet()
public
offsetGet(mixed $offset) : XmlNode
Parameters
- $offset : mixed
Return values
XmlNodeoffsetSet()
Sets the value at the specified offset in the data array.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
The offset where the value should be set.
- $value : mixed
-
The value to assign to the specified offset.
offsetUnset()
Unsets the value at the specified index.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
ToArray()
Converts the collection data to an array.
public
ToArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The array representation of the collection data.
ToString()
Converts the collection data to a string representation.
public
ToString([array<string|int, mixed>|null $splitters = null ][, mixed|null $mapFunction = null ]) : string
Parameters
- $splitters : array<string|int, mixed>|null = null
-
Optional array of splitters to join the data elements.
- $mapFunction : mixed|null = null
-
Optional mapping function to apply to each data element.
Tags
Return values
string —The string representation of the collection data.