CallbackGenerator
in package
implements
Iterator
Class \Hoa\Iterator\CallbackGenerator.
Yield a value based on a callback.
Tags
Table of Contents
Interfaces
- Iterator
- Interface \Hoa\Iterator.
Properties
- $_callback : callable
- Callback.
- $_current : mixed
- Current computed value.
- $_key : mixed
- Current key.
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
$_callback
Callback.
protected
callable
$_callback
= null
$_current
Current computed value.
protected
mixed
$_current
= null
$_key
Current key.
protected
mixed
$_key
= 0
Methods
__construct()
Constructor.
public
__construct(callable $callback) : mixed
Parameters
- $callback : callable
-
Callback.
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