style: apply php-cs-fixer formatting (PSR-12)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2026-03-09 20:46:59 +01:00
parent dae215dd3d
commit 7506a7a3c1
234 changed files with 447 additions and 370 deletions

View File

@@ -15,7 +15,8 @@ readonly class ListJobsQueryHandler implements QueryHandlerInterface
{
public function __construct(
private JobRepositoryInterface $jobRepository
) {}
) {
}
public function handle(QueryInterface $query): ResponseInterface
{

View File

@@ -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
{

View File

@@ -12,4 +12,4 @@ interface CommandHandlerInterface
* @return void
*/
public function handle(CommandInterface $command): void;
}
}

View File

@@ -6,4 +6,4 @@ namespace App\Domain\Shared\Domain\Contract;
interface CommandInterface
{
}
}

View File

@@ -12,4 +12,4 @@ interface FailedJobRepositoryInterface
public function findAll(): array;
public function findByJobType(string $jobType): array;
public function findRetryableJobs(): array;
}
}

View File

@@ -47,5 +47,3 @@ interface MangaPathManagerInterface
*/
public function fileExists(string $path): bool;
}

View File

@@ -13,4 +13,4 @@ interface QueryHandlerInterface
* @return R
*/
public function handle(QueryInterface $query): ResponseInterface;
}
}

View File

@@ -6,4 +6,4 @@ namespace App\Domain\Shared\Domain\Contract;
interface QueryInterface
{
}
}

View File

@@ -6,4 +6,4 @@ namespace App\Domain\Shared\Domain\Contract;
interface ResponseInterface
{
}
}

View File

@@ -11,7 +11,6 @@ readonly class ChapterImported
public int $volume,
public float|string $chapterNumber,
public string $cbzPath,
) {}
) {
}
}

View File

@@ -10,7 +10,6 @@ readonly class VolumeImported
public string $mangaSlug,
public int $volume,
public string $cbzPath,
) {}
) {
}
}

View File

@@ -13,4 +13,4 @@ class JobNotFoundException extends \DomainException
{
return new self(sprintf('Failed job with job id "%s" not found', $jobId));
}
}
}

View File

@@ -13,4 +13,4 @@ class JobNotRetryableException extends \DomainException
{
return new self(sprintf('Cannot retry job "%s" because it is not in failed status', $jobId));
}
}
}

View File

@@ -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
);
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -9,4 +9,4 @@ enum JobStatus: string
case COMPLETED = 'completed';
case FAILED = 'failed';
case CANCELLED = 'cancelled';
}
}

View File

@@ -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
{

View File

@@ -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,

View File

@@ -1,6 +1,7 @@
<?php
namespace App\Domain\Shared\Infrastructure\Messenger;
use App\Domain\Shared\Domain\Contract\EventDispatcherInterface;
use Symfony\Component\Messenger\MessageBusInterface;

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -107,5 +107,3 @@ readonly class MangaFileManager implements MangaPathManagerInterface
return $text ?: 'n-a';
}
}