Repeater
in package
implements
Iterator
Class \Hoa\Iterator\Repeater.
Repeat an iterator n-times.
Tags
Table of Contents
Interfaces
- Iterator
- Interface \Hoa\Iterator.
Properties
- $_body : callable
- Body (callable to execute each time).
- $_i : int
- Current repetition.
- $_iterator : Traversable
- Current iterator.
- $_n : int
- Maximum repetition.
Methods
- __construct() : mixed
- Constructor.
- current() : mixed
- Return the current element.
- key() : mixed
- Return the key of the current element.
- next() : void
- Move forward to next element.
- rewind() : void
- Rewind the iterator to the first element.
- valid() : bool
- Check if current position is valid.
Properties
$_body
Body (callable to execute each time).
protected
callable
$_body
= null
$_i
Current repetition.
protected
int
$_i
= 1
$_iterator
Current iterator.
protected
Traversable
$_iterator
= null
$_n
Maximum repetition.
protected
int
$_n
= 1
Methods
__construct()
Constructor.
public
__construct(Traversable $iterator, int $n[, callable $body = null ]) : mixed
Parameters
- $iterator : Traversable
-
Iterator.
- $n : int
-
Repeat $n-times.
- $body : callable = null
-
Body.
Tags
current()
Return the current element.
public
current() : mixed
key()
Return the key of the current element.
public
key() : mixed
next()
Move forward to next element.
public
next() : void
rewind()
Rewind the iterator to the first element.
public
rewind() : void
valid()
Check if current position is valid.
public
valid() : bool