Has public emit, complete, and fail methods. */ private $source; public function __construct() { $this->source = new Internal\EmitSource; } /** * Returns a Pipeline that can be given to an API consumer. This method may be called only once! * * @return Pipeline * * @psalm-return Pipeline * * @throws \Error If this method is called more than once. */ public function pipe(): Pipeline { return $this->source->pipe(); } /** * Emits a value to the pipeline. * * @param mixed $value * * @psalm-param TValue $value * * @return Promise Resolves with null when the emitted value has been consumed or fails with * {@see DisposedException} if the pipeline has been destroyed. */ public function emit($value): Promise { return $this->source->emit($value); } /** * @return bool True if the pipeline has been completed or failed. */ public function isComplete(): bool { return $this->source->isComplete(); } /** * @return bool True if the pipeline has been disposed. */ public function isDisposed(): bool { return $this->source->isDisposed(); } /** * @param callable():void $onDisposal * * @return void */ public function onDisposal(callable $onDisposal) { $this->source->onDisposal($onDisposal); } /** * Completes the pipeline. * * @return void */ public function complete() { $this->source->complete(); } /** * Fails the pipeline with the given reason. * * @param \Throwable $reason * * @return void */ public function fail(\Throwable $reason) { $this->source->fail($reason); } }