ldc-cocotte/app/Jobs/UpsertShopsPickupExceptionsUsingApiForYear.php

40 lines
1 KiB
PHP
Raw Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Contracts\Executor;
use App\Cqs\Actions\PickupExceptions\UpsertShopsPickupExceptionsUsingApiForYear as UpsertShopsPickupExceptionsAction;
use App\Cqs\Actions\PickupExceptions\UpsertShopsPickupExceptionsUsingApiForYearInput;
2026-06-14 21:32:07 +02:00
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Date;
class UpsertShopsPickupExceptionsUsingApiForYear implements ShouldQueue
{
use Queueable;
protected int $year;
public function __construct(?int $year = null)
{
$this->year = $year ?? Date::now()->addYear()->year;
throw_if(
$this->year < 2026,
\InvalidArgumentException::class
);
}
public function handle(
Executor $executor,
UpsertShopsPickupExceptionsAction $action,
): void {
$executor->execute(
$action,
new UpsertShopsPickupExceptionsUsingApiForYearInput($this->year),
2026-06-14 21:32:07 +02:00
);
}
}