<?php
declare(strict_types=1);

namespace App\Application\Contact;

use App\Domain\Contact\ContactMessage;
use App\Domain\Contact\ContactRepository;
use App\Framework\CommandBus\CommandHandler;

final readonly class StoreContactHandler
{
    public function __construct(
        private ContactRepository $contactRepository,
    ) {}
    #[CommandHandler]
    public function __invoke(StoreContact $command): void
    {
        $message = new ContactMessage($command->name, $command->email, $command->message);

        $this->contactRepository->save($message);
    }
}
