type = $type; $this->followUpJobs = $followUpJobs; $this->cooldownSeconds = $cooldownSeconds; $this->reason = $reason; } /** * Job completed successfully, optionally enqueue follow-up jobs. * * @param array $followUpJobs Array of ['type' => string, 'payload' => array, 'priority' => int, 'conflict_group' => string|null] * @return self */ public static function success(array $followUpJobs = []): self { return new self(self::TYPE_SUCCESS, $followUpJobs); } /** * Retry the job after a cooldown period. * * @param int $cooldownSeconds * @param string $reason * @return self */ public static function retry(int $cooldownSeconds, string $reason = ''): self { return new self(self::TYPE_RETRY, [], $cooldownSeconds, $reason); } /** * Permanent failure — do not retry. * * @param string $reason * @return self */ public static function fail(string $reason = ''): self { return new self(self::TYPE_FAIL, [], 0, $reason); } public function isSuccess(): bool { return $this->type === self::TYPE_SUCCESS; } public function isRetry(): bool { return $this->type === self::TYPE_RETRY; } public function isFail(): bool { return $this->type === self::TYPE_FAIL; } public function getFollowUpJobs(): array { return $this->followUpJobs; } public function getCooldownSeconds(): int { return $this->cooldownSeconds; } public function getReason(): string { return $this->reason; } }