SPL-StandardPHPLibrary
iteratoriterator.inc
Go to the documentation of this file.
1 <?php
2 
41 {
47  function __construct(Traversable $iterator, $classname = null)
48  {
49  if ($iterator instanceof IteratorAggregate)
50  {
51  $iterator = $iterator->getIterator();
52  }
53  if ($iterator instanceof Iterator)
54  {
55  $this->iterator = $iterator;
56  }
57  else
58  {
59  throw new Exception("Classes that only implement Traversable can be wrapped only after converting class IteratorIterator into c code");
60  }
61  }
62 
65  function getInnerIterator()
66  {
67  return $this->iterator;
68  }
69 
72  function valid()
73  {
74  return $this->iterator->valid();
75  }
76 
79  function key()
80  {
81  return $this->iterator->key();
82  }
83 
86  function current()
87  {
88  return $this->iterator->current();
89  }
90 
93  function next()
94  {
95  return $this->iterator->next();
96  }
97 
100  function rewind()
101  {
102  return $this->iterator->rewind();
103  }
104 
110  function __call($func, $params)
111  {
112  return call_user_func_array(array($this->iterator, $func), $params);
113  }
114 
118  private $iterator;
119 }
120 
121 ?>
__call($func, $params)
Aggregate the inner iterator.
Interface to create an external Iterator.
Definition: spl.php:533
__construct(Traversable $iterator, $classname=null)
Construct an IteratorIterator from an Iterator or an IteratorAggregate.
Basic Iterator wrapper.
Interface to access the current inner iteraor of iterator wrappers.
$iterator
The inner iterator must be private because when this class will be converted to c code it won&#39;t no lo...
next()
forward to next element
Basic iterator.
Definition: spl.php:549
Basic Exception class.
Definition: spl.php:258
rewind()
rewind to the first element
Interface to detect a class is traversable using foreach.
Definition: spl.php:523