Files
Mangarr/src/Domain/Shared/Infrastructure/Persistence/Mapper/FailedJobMapper.php

35 lines
1.1 KiB
PHP

<?php
namespace App\Domain\Shared\Infrastructure\Persistence\Mapper;
use App\Domain\Shared\Domain\Model\FailedJob;
use App\Domain\Shared\Infrastructure\Persistence\Entity\FailedJobEntity;
readonly class FailedJobMapper
{
public function toEntity(FailedJob $job): FailedJobEntity
{
$entity = new FailedJobEntity();
$entity->setId($job->id)
->setType($job->jobType)
->setFailureReason($job->failureReason)
->setFailedAt($job->failedAt)
->setContext($job->context);
return $entity;
}
public function toDomain(FailedJobEntity $entity): FailedJob
{
return new FailedJob(
id: $entity->getId(),
jobId: $entity->getId(), // On utilise le même ID car on n'a pas de référence au job original
jobType: $entity->getType(),
failureReason: $entity->getFailureReason(),
context: $entity->getContext(),
failedAt: $entity->getFailedAt(),
attempt: 1 // Par défaut car on n'a pas cette info dans l'entité
);
}
}