Exemple #1
0
 /**
  * Returns a complete iterator.
  * (an instance of \IteratorIterator which in turn
  * implements \OuterIterator).
  *
  * Use this method if you need to comply with type-hinting
  * from external libraries
  *
  * @return \IteratorIterator
  */
 public function toIterator()
 {
     $iterator = $this->unwrap();
     if (is_array($iterator)) {
         $iterator = new \ArrayIterator($iterator);
     }
     $appendIterator = new AppendIterator();
     $appendIterator->append($iterator);
     return new PipeIterator($appendIterator);
 }
Exemple #2
0
 public function append($iterator)
 {
     if (is_array($iterator)) {
         $iterator = new \ArrayIterator($iterator);
     }
     $me = $this;
     while (is_a($me, '\\Pipes\\PipeIterator')) {
         $me = $me->getInnerIterator();
     }
     if (is_a($me, '\\Pipes\\Iterator\\AppendIterator')) {
         $appendIterator = $me;
     } else {
         $appendIterator = new AppendIterator();
         $appendIterator->append($me->toIterator());
     }
     $appendIterator->append($iterator);
     return $this->getRoot()->chainWith($appendIterator);
 }