id, $message->body, $message->timestamp, $message->attempts, $consumer, ); } public function isProcessed(): bool { return $this->processed; } /** * @psalm-return Promise */ public function finish(): Promise { $this->markAsProcessedOrFail(); return $this->consumer->fin($this->id); } /** * @psalm-param positive-int|0 $timeout * * @psalm-return Promise */ public function requeue(int $timeout): Promise { $this->markAsProcessedOrFail(); return $this->consumer->req($this->id, $timeout); } /** * @psalm-return Promise */ public function touch(): Promise { if ($this->processed) { throw MessageException::processed($this); } return $this->consumer->touch($this->id); } private function markAsProcessedOrFail(): void { if ($this->processed) { throw MessageException::processed($this); } $this->processed = true; } }