Files
Mangarr/src/Domain/Shared/Application/CommandHandler/DeleteJobHandler.php
ext.jeremy.guillot@maxicoffee.domains 19395b4869 feat: activity page
2026-03-11 20:54:55 +01:00

33 lines
931 B
PHP

<?php
declare(strict_types=1);
namespace App\Domain\Shared\Application\CommandHandler;
use App\Domain\Shared\Application\Command\DeleteJob;
use App\Domain\Shared\Domain\Contract\CommandHandlerInterface;
use App\Domain\Shared\Domain\Contract\CommandInterface;
use App\Domain\Shared\Domain\Contract\JobRepositoryInterface;
readonly class DeleteJobHandler implements CommandHandlerInterface
{
public function __construct(
private JobRepositoryInterface $jobRepository
) {
}
public function handle(CommandInterface $command): void
{
if (!$command instanceof DeleteJob) {
throw new \InvalidArgumentException(sprintf(
'Command must be instance of %s, %s given',
DeleteJob::class,
get_class($command)
));
}
$this->jobRepository->get($command->id);
$this->jobRepository->delete($command->id);
}
}