<?php

namespace App\Domain\Manga\Infrastructure\ApiPlatform\State\Processor;

use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\Domain\Manga\Application\Command\DeleteCbz;
use App\Domain\Manga\Application\CommandHandler\DeleteCbzHandler;
use App\Domain\Manga\Infrastructure\ApiPlatform\Resource\DeleteCbzResource;

readonly class DeleteCbzProcessor implements ProcessorInterface
{
    public function __construct(
        private DeleteCbzHandler $handler
    ) {
    }

    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): void
    {
        assert($data instanceof DeleteCbzResource);

        $command = new DeleteCbz($data->id);
        $this->handler->handle($command);
    }
}
