1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 18:38:17 +01:00
amp/lib/Internal/PrivateIterator.php

46 lines
890 B
PHP
Raw Normal View History

<?php
namespace Amp\Internal;
use Amp\Iterator;
use Amp\Promise;
/**
* Wraps an Iterator instance that has public methods to emit, complete, and fail into an object that only allows
* access to the public API methods.
*
* @template-covariant TValue
* @template-implements Iterator<TValue>
*/
final class PrivateIterator implements Iterator
2018-06-18 20:00:01 +02:00
{
/** @var Iterator<TValue> */
private $iterator;
/**
* @param Iterator $iterator
*
* @psalm-param Iterator<TValue> $iterator
*/
2018-06-18 20:00:01 +02:00
public function __construct(Iterator $iterator)
{
$this->iterator = $iterator;
}
/**
* @return Promise<bool>
*/
2018-06-18 20:00:01 +02:00
public function advance(): Promise
{
return $this->iterator->advance();
}
/**
* @psalm-return TValue
*/
2018-06-18 20:00:01 +02:00
public function getCurrent()
{
return $this->iterator->getCurrent();
}
}