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

Public Member Functions

 __construct (\Traversable $iterator, $demuxer)
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Attributes

 $_iterator = null
 
 $_current = null
 
 $_demuxer = null
 

Detailed Description

Class .

Demux result from another iterator. This iterator is somehow the opposite of the Hoa iterator.

Definition at line 48 of file Demultiplexer.php.

Constructor & Destructor Documentation

Hoa\Iterator\Demultiplexer::__construct ( \Traversable  $iterator,
  $demuxer 
)

Constructor.

Parameters
\Traversable$iteratorIterator.
callable$demuxerDemuxer.
Returns
void
Exceptions

Definition at line 81 of file Demultiplexer.php.

82  {
83  if ($iterator instanceof \IteratorAggregate) {
84  $iterator = $iterator->getIterator();
85  }
86 
87  $this->_iterator = $iterator;
88  $this->_demuxer = $demuxer;
89 
90  return;
91  }

Member Function Documentation

Hoa\Iterator\Demultiplexer::current ( )

Return the current element.

Returns
mixed

Definition at line 98 of file Demultiplexer.php.

99  {
100  if (null !== $this->_current) {
101  return $this->_current;
102  }
103 
104  $demuxer = $this->_demuxer;
105 
106  return $this->_current = $demuxer($this->_iterator->current());
107  }
Hoa\Iterator\Demultiplexer::key ( )

Return the key of the current element.

Returns
mixed

Definition at line 114 of file Demultiplexer.php.

115  {
116  return $this->_iterator->key();
117  }
Hoa\Iterator\Demultiplexer::next ( )

Move forward to next element.

Returns
void

Definition at line 124 of file Demultiplexer.php.

125  {
126  $this->_current = null;
127 
128  return $this->_iterator->next();
129  }
Hoa\Iterator\Demultiplexer::rewind ( )

Rewind the iterator to the first element.

Returns
void

Definition at line 136 of file Demultiplexer.php.

137  {
138  return $this->_iterator->rewind();
139  }
Hoa\Iterator\Demultiplexer::valid ( )

Check if current position is valid.

Returns
bool

Definition at line 146 of file Demultiplexer.php.

147  {
148  return $this->_iterator->valid();
149  }

Member Data Documentation

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

Definition at line 62 of file Demultiplexer.php.

Hoa\Iterator\Demultiplexer::$_demuxer = null
protected

Definition at line 69 of file Demultiplexer.php.

Hoa\Iterator\Demultiplexer::$_iterator = null
protected

Definition at line 55 of file Demultiplexer.php.


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