Files
Mangarr/src/Domain/Shared/Application/Response/JobResponse.php
ext.jeremy.guillot@maxicoffee.domains 19395b4869 feat: activity page
2026-03-11 20:54:55 +01:00

42 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Domain\Shared\Application\Response;
use App\Domain\Shared\Domain\Contract\ResponseInterface;
use App\Domain\Shared\Domain\Model\Job;
readonly class JobResponse implements ResponseInterface
{
public function __construct(
public string $id,
public string $type,
public string $status,
public \DateTimeImmutable $createdAt,
public ?\DateTimeImmutable $startedAt,
public ?\DateTimeImmutable $completedAt,
public ?string $failureReason,
public int $attempts,
public int $maxAttempts,
public array $context
) {
}
public static function fromJob(Job $job): self
{
return new self(
id: $job->id,
type: $job->type,
status: $job->status->value,
createdAt: $job->createdAt,
startedAt: $job->startedAt,
completedAt: $job->completedAt,
failureReason: $job->failureReason,
attempts: $job->attempts,
maxAttempts: $job->maxAttempts,
context: $job->context
);
}
}