Iterator
in package
implements
IteratorAggregate
Extended version of PHP's iterator class that builds the foundation of our Collection class.
Interfaces, Classes, Traits and Enums
- IteratorAggregate
Table of Contents
- $data : array<string|int, mixed>
- The data array
- __construct() : mixed
- Constructor
- __isset() : bool
- Checks if the current key is set
- count() : int
- Counts all elements
- current() : mixed
- Returns the current element
- getIterator() : ArrayIterator
- Get an iterator for the items.
- has() : bool
- Checks by key if an element is included
- indexOf() : int|false
- Tries to find the index number for the given element
- key() : string
- Returns the current key
- keyOf() : string|false
- Tries to find the key for the given element
- keys() : array<string|int, mixed>
- Returns an array of all keys
- next() : mixed
- Moves the cursor to the next element and returns it
- prev() : mixed
- Moves the cursor to the previous element and returns it
- rewind() : mixed
- Moves the cursor to the first element
- valid() : bool
- Checks if the current element is valid
Properties
$data
The data array
public
array<string|int, mixed>
$data
= []
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = []
Return values
mixed —__isset()
Checks if the current key is set
public
__isset(mixed $key) : bool
Parameters
- $key : mixed
-
the key to check
Return values
bool —count()
Counts all elements
public
count() : int
Return values
int —current()
Returns the current element
public
current() : mixed
Return values
mixed —getIterator()
Get an iterator for the items.
public
getIterator() : ArrayIterator
Return values
ArrayIterator —has()
Checks by key if an element is included
public
has(mixed $key) : bool
Parameters
- $key : mixed
Return values
bool —indexOf()
Tries to find the index number for the given element
public
indexOf(mixed $needle) : int|false
Parameters
- $needle : mixed
-
the element to search for
Return values
int|false —the index (int) of the element or false
key()
Returns the current key
public
key() : string
Return values
string —keyOf()
Tries to find the key for the given element
public
keyOf(mixed $needle) : string|false
Parameters
- $needle : mixed
-
the element to search for
Return values
string|false —the name of the key or false
keys()
Returns an array of all keys
public
keys() : array<string|int, mixed>
Return values
array<string|int, mixed> —next()
Moves the cursor to the next element and returns it
public
next() : mixed
Return values
mixed —prev()
Moves the cursor to the previous element and returns it
public
prev() : mixed
Return values
mixed —rewind()
Moves the cursor to the first element
public
rewind() : mixed
Return values
mixed —valid()
Checks if the current element is valid
public
valid() : bool