<?php

namespace VulnTitan\SpamProtection;

use VulnTitan\SpamProtection\Providers\ContactForm7ProviderAdapter;
use VulnTitan\SpamProtection\Providers\FluentFormsProviderAdapter;

class FormProviderRegistry
{
    /**
     * @return array<int,FormProviderAdapterInterface>
     */
    public static function all(): array
    {
        $providers = [
            new ContactForm7ProviderAdapter(),
            new FluentFormsProviderAdapter(),
        ];

        $providers = apply_filters('vulntitan_form_spam_providers', $providers);

        if (!is_array($providers)) {
            return [];
        }

        return array_values(array_filter($providers, static function ($provider): bool {
            return $provider instanceof FormProviderAdapterInterface;
        }));
    }
}
