ldc-cocotte/app/Jobs/UpsertShopsPickupExceptionsUsingApiForYear.php

39 lines
1 KiB
PHP

<?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;
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),
);
}
}