Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Iterator\CallbackGenerator Class Reference
Inheritance diagram for Hoa\Iterator\CallbackGenerator:

Public Member Functions

 __construct (callable $callback)
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Attributes

 $_callback = null
 
 $_key = 0
 
 $_current = null
 

Detailed Description

Class .

Yield a value based on a callback.

Definition at line 47 of file CallbackGenerator.php.

Constructor & Destructor Documentation

Hoa\Iterator\CallbackGenerator::__construct ( callable  $callback)

Constructor.

Parameters
callable$callbackCallback.
Returns
void

Definition at line 78 of file CallbackGenerator.php.

79  {
80  $this->_callback = $callback;
81 
82  return;
83  }

Member Function Documentation

Hoa\Iterator\CallbackGenerator::current ( )

Return the current element.

Returns
mixed

Definition at line 90 of file CallbackGenerator.php.

91  {
92  $handle = $this->_callback;
93 
94  return $this->_current = $handle($this->_key);
95  }
Hoa\Iterator\CallbackGenerator::key ( )

Return the key of the current element.

Returns
mixed

Definition at line 102 of file CallbackGenerator.php.

103  {
104  return $this->_key;
105  }
Hoa\Iterator\CallbackGenerator::next ( )

Move forward to next element.

Returns
void

Definition at line 112 of file CallbackGenerator.php.

113  {
114  ++$this->_key;
115 
116  return;
117  }
Hoa\Iterator\CallbackGenerator::rewind ( )

Rewind the iterator to the first element.

Returns
void

Definition at line 124 of file CallbackGenerator.php.

125  {
126  $this->_key = 0;
127  $this->_current = null;
128 
129  return;
130  }
Hoa\Iterator\CallbackGenerator::valid ( )

Check if current position is valid.

Returns
bool

Definition at line 137 of file CallbackGenerator.php.

138  {
139  return true;
140  }

Member Data Documentation

Hoa\Iterator\CallbackGenerator::$_callback = null
protected

Definition at line 54 of file CallbackGenerator.php.

Hoa\Iterator\CallbackGenerator::$_current = null
protected

Definition at line 68 of file CallbackGenerator.php.

Hoa\Iterator\CallbackGenerator::$_key = 0
protected

Definition at line 61 of file CallbackGenerator.php.


The documentation for this class was generated from the following file: