SPL-StandardPHPLibrary
filteriterator.inc
Go to the documentation of this file.
1 <?php
2 
26 abstract class FilterIterator implements OuterIterator
27 {
28  private $it;
29 
35  function __construct(Iterator $it) {
36  $this->it = $it;
37  }
38 
42  function rewind() {
43  $this->it->rewind();
44  $this->fetch();
45  }
46 
54  abstract function accept();
55 
61  protected function fetch() {
62  while ($this->it->valid()) {
63  if ($this->accept()) {
64  return;
65  }
66  $this->it->next();
67  };
68  }
69 
75  function next() {
76  $this->it->next();
77  $this->fetch();
78  }
79 
83  function valid() {
84  return $this->it->valid();
85  }
86 
90  function key() {
91  return $this->it->key();
92  }
93 
97  function current() {
98  return $this->it->current();
99  }
100 
104  protected function __clone() {
105  // disallow clone
106  }
107 
111  function getInnerIterator()
112  {
113  return $this->it;
114  }
115 
121  function __call($func, $params)
122  {
123  return call_user_func_array(array($this->it, $func), $params);
124  }
125 }
126 
127 ?>
__clone()
hidden __clone
Interface to access the current inner iteraor of iterator wrappers.
next()
Move to next element.
fetch()
Fetch next element and store it.
Abstract filter for iterators.
__construct(Iterator $it)
Constructs a filter around another iterator.
Basic iterator.
Definition: spl.php:549
rewind()
Rewind the inner iterator.
__call($func, $params)
Aggregate the inner iterator.
accept()
Accept function to decide whether an element of the inner iterator should be accessible through the F...