tube = new PBA\Values\TubeName($tubeName); } protected PBA\Values\TubeName $tube; public function set(string $payload, int $delay = 0): self { $this->client->useTube($this->tube); $this->client->put($payload, $delay); return $this; } public function pending(): int { $stats = $this->client->statsTube($this->tube); return $stats->currentJobsReady; } public function exists(?int $jobId = null): bool { return $this->pending() > 0; } protected int $currentJobId; public function get(?int $jobId = null): string { $this->client->watch($this->tube); if ($jobId !== null) { $jobId = new PBA\Values\JobId($jobId); $job = $this->client->reserveJob($jobId); } else { $job = $this->client->reserve(); } $this->currentJobId = $job->getId(); return $job->getData(); } public function update(string $newPayload, ?int $jobId = null): self { $this->remove($jobId); $this->set($newPayload); return $this; } public function remove(?int $jobId = null): self { if ($jobId === null) { $jobId = $this->currentJobId; } $this->client->watch($this->tube); $this->client->delete(new PBA\Values\JobId($jobId)); return $this; } }