<?php

namespace App\Domain\Scraping\Application\Command;

readonly class SetMangaPreferredSources
{
    public function __construct(
        public string $mangaId,
        public array $sourceIds
    ) {
        if (empty($mangaId)) {
            throw new \InvalidArgumentException('Manga ID cannot be empty');
        }

        if (!is_array($sourceIds)) {
            throw new \InvalidArgumentException('Source IDs must be an array');
        }

        // Valider que tous les éléments sont des strings
        foreach ($sourceIds as $sourceId) {
            if (!is_string($sourceId) && !is_int($sourceId)) {
                throw new \InvalidArgumentException('All source IDs must be strings or integers');
            }
        }
    }
}
