style: apply php-cs-fixer formatting (PSR-12)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
dae215dd3d
commit
7506a7a3c1
@@ -15,7 +15,8 @@ readonly class ListJobsQueryHandler implements QueryHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private JobRepositoryInterface $jobRepository
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(QueryInterface $query): ResponseInterface
|
||||
{
|
||||
|
||||
@@ -18,7 +18,8 @@ readonly class JobListResponse implements ResponseInterface
|
||||
public int $page,
|
||||
public int $limit,
|
||||
public int $pages
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public static function fromJobs(array $jobs, int $total, int $page, int $limit): self
|
||||
{
|
||||
|
||||
@@ -12,4 +12,4 @@ interface CommandHandlerInterface
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CommandInterface $command): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ namespace App\Domain\Shared\Domain\Contract;
|
||||
|
||||
interface CommandInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,4 @@ interface FailedJobRepositoryInterface
|
||||
public function findAll(): array;
|
||||
public function findByJobType(string $jobType): array;
|
||||
public function findRetryableJobs(): array;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +47,3 @@ interface MangaPathManagerInterface
|
||||
*/
|
||||
public function fileExists(string $path): bool;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,4 +13,4 @@ interface QueryHandlerInterface
|
||||
* @return R
|
||||
*/
|
||||
public function handle(QueryInterface $query): ResponseInterface;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ namespace App\Domain\Shared\Domain\Contract;
|
||||
|
||||
interface QueryInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ namespace App\Domain\Shared\Domain\Contract;
|
||||
|
||||
interface ResponseInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ readonly class ChapterImported
|
||||
public int $volume,
|
||||
public float|string $chapterNumber,
|
||||
public string $cbzPath,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ readonly class VolumeImported
|
||||
public string $mangaSlug,
|
||||
public int $volume,
|
||||
public string $cbzPath,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,4 +13,4 @@ class JobNotFoundException extends \DomainException
|
||||
{
|
||||
return new self(sprintf('Failed job with job id "%s" not found', $jobId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ class JobNotRetryableException extends \DomainException
|
||||
{
|
||||
return new self(sprintf('Cannot retry job "%s" because it is not in failed status', $jobId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ class FailedJob
|
||||
public readonly array $context,
|
||||
public readonly \DateTimeImmutable $failedAt,
|
||||
public readonly int $attempt
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public static function fromJob(Job $job): self
|
||||
{
|
||||
@@ -26,4 +27,4 @@ class FailedJob
|
||||
attempt: $job->attempts
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,36 +21,36 @@ abstract class Job
|
||||
$this->createdAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function start(): void
|
||||
public function start(): void
|
||||
{
|
||||
$this->status = JobStatus::IN_PROGRESS;
|
||||
$this->startedAt = new \DateTimeImmutable();
|
||||
$this->attempts++;
|
||||
}
|
||||
|
||||
public function complete(): void
|
||||
public function complete(): void
|
||||
{
|
||||
$this->status = JobStatus::COMPLETED;
|
||||
$this->completedAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function fail(string $reason): void
|
||||
public function fail(string $reason): void
|
||||
{
|
||||
$this->failureReason = $reason;
|
||||
$this->status = $this->attempts >= $this->maxAttempts
|
||||
? JobStatus::FAILED
|
||||
$this->status = $this->attempts >= $this->maxAttempts
|
||||
? JobStatus::FAILED
|
||||
: JobStatus::PENDING;
|
||||
$this->completedAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function cancel(): void
|
||||
public function cancel(): void
|
||||
{
|
||||
$this->status = JobStatus::CANCELLED;
|
||||
$this->completedAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function canBeRetried(): bool
|
||||
public function canBeRetried(): bool
|
||||
{
|
||||
return $this->status === JobStatus::FAILED && $this->attempts < $this->maxAttempts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ enum JobStatus: string
|
||||
case COMPLETED = 'completed';
|
||||
case FAILED = 'failed';
|
||||
case CANCELLED = 'cancelled';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,39 +116,31 @@ class GetJobListResource
|
||||
description: 'Identifiant unique du job'
|
||||
)]
|
||||
public readonly string $id,
|
||||
|
||||
#[ApiProperty(description: 'Type du job (ex: scraping_job)')]
|
||||
#[Assert\NotBlank]
|
||||
public readonly string $type,
|
||||
|
||||
#[ApiProperty(description: 'Status du job')]
|
||||
#[Assert\NotBlank]
|
||||
public readonly string $status,
|
||||
|
||||
#[ApiProperty(description: 'Date de création du job')]
|
||||
#[Assert\NotNull]
|
||||
public readonly \DateTimeImmutable $createdAt,
|
||||
|
||||
#[ApiProperty(description: 'Date de début d\'exécution du job')]
|
||||
public readonly ?\DateTimeImmutable $startedAt = null,
|
||||
|
||||
#[ApiProperty(description: 'Date de fin d\'exécution du job')]
|
||||
public readonly ?\DateTimeImmutable $completedAt = null,
|
||||
|
||||
#[ApiProperty(description: 'Raison de l\'échec si le job a échoué')]
|
||||
public readonly ?string $failureReason = null,
|
||||
|
||||
#[ApiProperty(description: 'Nombre de tentatives effectuées')]
|
||||
#[Assert\GreaterThanOrEqual(0)]
|
||||
public readonly int $attempts = 0,
|
||||
|
||||
#[ApiProperty(description: 'Nombre maximum de tentatives autorisées')]
|
||||
#[Assert\GreaterThan(0)]
|
||||
public readonly int $maxAttempts = 3,
|
||||
|
||||
#[ApiProperty(description: 'Données contextuelles du job')]
|
||||
public readonly array $context = []
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public static function fromJob(\App\Domain\Shared\Domain\Model\Job $job): self
|
||||
{
|
||||
|
||||
@@ -16,7 +16,8 @@ readonly class GetJobListStateProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ListJobsQueryHandler $handler
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ArrayPaginator
|
||||
{
|
||||
@@ -63,7 +64,7 @@ readonly class GetJobListStateProvider implements ProviderInterface
|
||||
|
||||
return new ArrayPaginator(
|
||||
array_map(
|
||||
fn($job) => GetJobListResource::fromJob($job),
|
||||
fn ($job) => GetJobListResource::fromJob($job),
|
||||
$response->items
|
||||
),
|
||||
0,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Shared\Infrastructure\Messenger;
|
||||
|
||||
use App\Domain\Shared\Domain\Contract\EventDispatcherInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ readonly class DoctrineFailedJobRepository implements FailedJobRepositoryInterfa
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return array_map(fn(FailedJobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
return array_map(fn (FailedJobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
}
|
||||
|
||||
public function findById(string $id): ?FailedJob
|
||||
@@ -81,10 +81,10 @@ readonly class DoctrineFailedJobRepository implements FailedJobRepositoryInterfa
|
||||
->getResult();
|
||||
|
||||
return array_map(
|
||||
fn(FailedJobEntity $entity) => $this->mapper->toDomain($entity),
|
||||
fn (FailedJobEntity $entity) => $this->mapper->toDomain($entity),
|
||||
array_filter(
|
||||
$entities,
|
||||
fn(FailedJobEntity $entity) => $this->mapper->toDomain($entity)->attempt < 3
|
||||
fn (FailedJobEntity $entity) => $this->mapper->toDomain($entity)->attempt < 3
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -99,6 +99,6 @@ readonly class DoctrineFailedJobRepository implements FailedJobRepositoryInterfa
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return array_map(fn(FailedJobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
return array_map(fn (FailedJobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ readonly class DoctrineJobRepository implements JobRepositoryInterface
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return array_map(fn(JobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
return array_map(fn (JobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
}
|
||||
|
||||
public function findPendingJobs(): array
|
||||
@@ -98,7 +98,7 @@ readonly class DoctrineJobRepository implements JobRepositoryInterface
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return array_map(fn(JobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
return array_map(fn (JobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
}
|
||||
|
||||
public function findByCriteria(array $criteria): array
|
||||
@@ -149,7 +149,7 @@ readonly class DoctrineJobRepository implements JobRepositoryInterface
|
||||
|
||||
$entities = $qb->getQuery()->getResult();
|
||||
|
||||
return array_map(fn(JobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
return array_map(fn (JobEntity $entity) => $this->mapper->toDomain($entity), $entities);
|
||||
}
|
||||
|
||||
public function countByCriteria(array $criteria): int
|
||||
|
||||
@@ -107,5 +107,3 @@ readonly class MangaFileManager implements MangaPathManagerInterface
|
||||
return $text ?: 'n-a';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user