<?php
declare(strict_types=1);

namespace Ekesto\CacheInvalidator\Integrations\Forms\Adapters;

/**
 * Shared form ID normalization for form adapters.
 */
trait NormalizesFormIds
{
    /**
     * Normalize raw extracted IDs: trim, deduplicate, remove empties.
     *
     * @param array<int,mixed> $ids Raw IDs.
     * @return string[]
     */
    private function normalizeIds(array $ids): array
    {
        return array_values(array_unique(array_filter(array_map(
            static fn($value): string => trim((string) $value),
            $ids
        ))));
    }
}
