Methods summary
public
|
|
public
|
#
getIterator( )
Implements \IteratorAggregate::getIterator().
Implements \IteratorAggregate::getIterator().
Implementation of
IteratorAggregate::getIterator()
|
public
|
#
count( )
Implements \Countable::count().
Implements \Countable::count().
Implementation of
Countable::count()
|
public
boolean
|
#
offsetExists( integer $offset )
Implements \ArrayAccess::offsetExists().
Implements \ArrayAccess::offsetExists().
Parameters
Returns
boolean
Implementation of
ArrayAccess::offsetExists()
|
public
Pharborist\Node
|
#
offsetGet( integer $offset )
Implements \ArrayAccess::offsetGet().
Implements \ArrayAccess::offsetGet().
Parameters
Returns
Implementation of
ArrayAccess::offsetGet()
|
public
|
#
offsetSet( integer $offset, Pharborist\Node $value )
Implements \ArrayAccess::offsetSet().
Implements \ArrayAccess::offsetSet().
Parameters
Throws
BadMethodCallException
Implementation of
ArrayAccess::offsetSet()
|
public
|
#
offsetUnset( integer $offset )
Implements \ArrayAccess::offsetUnset().
Implements \ArrayAccess::offsetUnset().
Parameters
Throws
BadMethodCallException
Implementation of
ArrayAccess::offsetUnset()
|
public
boolean
|
#
isEmpty( )
Returns if the collection is empty.
Returns if the collection is empty.
Returns
boolean
|
public
boolean
|
#
isNotEmpty( )
Returns if the collection is not empty.
Returns if the collection is not empty.
Returns
boolean
|
public
Pharborist\Node[]
|
#
reverse( )
Get collection in reverse order
Get collection in reverse order
Returns
|
public
Pharborist\NodeCollection
|
#
slice( integer $start_index, integer $end_index = NULL )
Reduce the set of matched nodes to a subset specified by a range.
Reduce the set of matched nodes to a subset specified by a range.
Parameters
Returns
|
public
Pharborist\NodeCollection
|
#
map( callable $callback )
Creates a new collection by applying a callback to each node in the matched
set, like jQuery's .map().
Creates a new collection by applying a callback to each node in the matched
set, like jQuery's .map().
Parameters
- $callback
- The callback to apply, receiving the current node in the set.
Returns
|
public
mixed
|
#
reduce( callable $callback, mixed $initial = NULL )
Iteratively reduce the collection to a single value using a callback.
Iteratively reduce the collection to a single value using a callback.
Parameters
- $callback
Callback function that receives the return value of the previous
iteration and the current node in the set being processed.
- $initial
The initial value for first iteration, or final result in case
of empty collection.
Returns
mixed Returns the resulting value.
|
public
Pharborist\Node[]
|
#
toArray( )
Returns the raw array of nodes, like jQuery's get() called with no
arguments.
Returns the raw array of nodes, like jQuery's get() called with no
arguments.
Returns
|
public
Pharborist\Node
|
#
get( integer $index )
Get the element at index.
Get the element at index.
Parameters
- $index
- Index of element to get.
Returns
|
public
integer
|
#
indexOf( callable $callback )
Index of first element that is matched by callback.
Index of first element that is matched by callback.
Parameters
- $callback
- Callback to test for node match.
Returns
integer Index of first element that is matched by callback.
|
public
boolean
|
#
is( callable $callback )
Test is any element in collection matches.
Test is any element in collection matches.
Parameters
- $callback
- Callback to test for node match.
Returns
boolean TRUE if any element in set of nodes matches.
|
public
Pharborist\NodeCollection
|
#
parent( callable $callback = NULL )
Get the parent of each node in the current set of matched nodes,
optionally filtered by a callback.
Get the parent of each node in the current set of matched nodes,
optionally filtered by a callback.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
parents( callable $callback = NULL )
Get the ancestors of each node in the current set of matched nodes,
optionally filtered by a callback.
Get the ancestors of each node in the current set of matched nodes,
optionally filtered by a callback.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
parentsUntil( callable $callback, boolean $inclusive = FALSE )
Get ancestors of each node in the current set of matched nodes,
up to the node matched by callback.
Get ancestors of each node in the current set of matched nodes,
up to the node matched by callback.
Parameters
- $callback
- Callback to test for match.
- $inclusive
- TRUE to include the node matched by callback.
Returns
|
public
Pharborist\Node
|
#
closest( callable $callback )
For each node in the collection, get the first node matched by the
callback by testing this node and traversing up through its ancestors in
the tree.
For each node in the collection, get the first node matched by the
callback by testing this node and traversing up through its ancestors in
the tree.
Parameters
- $callback
- Callback to test for match.
Returns
|
public
Pharborist\NodeCollection
|
#
children( callable $callback = NULL )
Get the immediate children of each node in the set of matched nodes.
Get the immediate children of each node in the set of matched nodes.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
|
#
clear( )
Remove all child nodes of the set of matched elements.
Remove all child nodes of the set of matched elements.
Returns
$this
|
public
Pharborist\NodeCollection
|
#
previous( callable $callback = NULL )
Get the immediately preceding sibling of each node in the set of matched
nodes. If a callback is provided, it retrieves the next sibling only if
the callback returns TRUE.
Get the immediately preceding sibling of each node in the set of matched
nodes. If a callback is provided, it retrieves the next sibling only if
the callback returns TRUE.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
previousAll( callable $callback = NULL )
Get all preceding siblings of each node in the set of matched nodes,
optionally filtered by a callback.
Get all preceding siblings of each node in the set of matched nodes,
optionally filtered by a callback.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
previousUntil( callable $callback, boolean $inclusive = FALSE )
Get all preceding siblings of each node up to the node matched by the
callback.
Get all preceding siblings of each node up to the node matched by the
callback.
Parameters
- $callback
- Callback to test for match.
- $inclusive
- TRUE to include the node matched by callback.
Returns
|
public
Pharborist\NodeCollection
|
#
next( callable $callback = NULL )
Get the immediately following sibling of each node in the set of matched
nodes. If a callback is provided, it retrieves the next sibling only if
the callback returns TRUE.
Get the immediately following sibling of each node in the set of matched
nodes. If a callback is provided, it retrieves the next sibling only if
the callback returns TRUE.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
nextAll( callable $callback = NULL )
Get all following siblings of each node in the set of matched nodes,
optionally filtered by a callback.
Get all following siblings of each node in the set of matched nodes,
optionally filtered by a callback.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
nextUntil( callable $callback, boolean $inclusive = FALSE )
Get all following siblings of each node up to the node matched by the
callback.
Get all following siblings of each node up to the node matched by the
callback.
Parameters
- $callback
- Callback to test for match.
- $inclusive
- TRUE to include the node matched by callback.
Returns
|
public
Pharborist\NodeCollection
|
#
siblings( callable $callback = NULL )
Get the siblings of each node in the set of matched nodes,
optionally filtered by a callback.
Get the siblings of each node in the set of matched nodes,
optionally filtered by a callback.
Parameters
- $callback
- An optional callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
find( callable $callback )
Get the descendants of each node in the current set of matched nodes,
filtered by callback.
Get the descendants of each node in the current set of matched nodes,
filtered by callback.
Parameters
- $callback
- Callback to filter by.
Returns
|
public
Pharborist\NodeCollection
|
#
filter( callable $callback )
Reduce the set of matched nodes to those that pass the callback filter.
Reduce the set of matched nodes to those that pass the callback filter.
Parameters
- $callback
- Callback to test for match.
Returns
|
public
Pharborist\NodeCollection
|
#
not( callable $callback )
Remove nodes from the set of matched nodes.
Remove nodes from the set of matched nodes.
Parameters
- $callback
- Callback to test for match.
Returns
|
public
Pharborist\NodeCollection
|
#
has( callable $callback )
Reduce the set of matched nodes to those that have a descendant that
match.
Reduce the set of matched nodes to those that have a descendant that
match.
Parameters
- $callback
- Callback to test for match.
Returns
|
public
|
#
first( )
Reduce the set of matched nodes to the first in the set.
Reduce the set of matched nodes to the first in the set.
|
public
|
#
last( )
Reduce the set of matched nodes to the last in the set.
Reduce the set of matched nodes to the last in the set.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
remove( )
Remove the set of matched nodes from the tree.
Remove the set of matched nodes from the tree.
Returns
$this
|
public
|
#
replaceWith( Pharborist\Node |Pharborist\Node[] |Pharborist\NodeCollection $nodes )
Replace each node in the set of matched nodes with the provided new nodes
and return the set of nodes that was removed.
Replace each node in the set of matched nodes with the provided new nodes
and return the set of nodes that was removed.
Parameters
- $nodes
- Replacement nodes.
Returns
$this
|
public
|
|
public
|
|
public
static
|
#
addTo( Pharborist\NodeCollection $collection )
Merges the current collection with another one, and returns the other one.
Merges the current collection with another one, and returns the other one.
Parameters
- $collection
- The destination collection.
Returns
static
|
public
|
#
each( callable $callback )
Apply callback on each element in the node collection.
Apply callback on each element in the node collection.
Parameters
- $callback
- Callback to apply on each element.
Returns
$this
|
public
|
|