本文整理汇总了PHP中Iterator::getIterator方法的典型用法代码示例。如果您正苦于以下问题:PHP Iterator::getIterator方法的具体用法?PHP Iterator::getIterator怎么用?PHP Iterator::getIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iterator
的用法示例。
在下文中一共展示了Iterator::getIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param \Traversable $iterator
* @param Callable $callback
*/
public function __construct(\Traversable $iterator, $callback)
{
$this->_iterator = $iterator;
while ($this->_iterator instanceof \IteratorAggregate) {
$this->_iterator = $this->_iterator->getIterator();
}
$this->_callback = $callback;
}
示例2: project
private function project()
{
$projection = $this->projection;
$this->currentIterator = $projection($this->innerIterator->current(), $this->innerIterator->key(), $this->innerIterator);
if ($this->currentIterator instanceof \IteratorAggregate) {
$this->currentIterator = $this->currentIterator->getIterator();
} elseif ($this->currentIterator instanceof \Iterator !== true) {
throw new \BadMethodCallException('Projection did not return an iterator');
}
$this->projectionNeeded = false;
}