<?php

namespace App\Providers;

use App\Contracts\Communications\EmailChannelProvider;
use App\Contracts\Communications\SmsChannelProvider;
use App\Services\Communications\Placeholders\DefaultPlaceholders;
use App\Services\Communications\Placeholders\PlaceholderRegistry;
use App\Services\Communications\Providers\SendGridEmailProvider;
use App\Services\Communications\Providers\TwilioSmsProvider;
use Illuminate\Support\ServiceProvider;

class ContactCommunicationsServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        // Singleton registry — placeholders are registered once per request.
        $this->app->singleton(PlaceholderRegistry::class, function () {
            $registry = new PlaceholderRegistry();
            DefaultPlaceholders::register($registry);
            return $registry;
        });

        // Provider bindings — swap via container when mocking in tests.
        $this->app->bind(EmailChannelProvider::class, SendGridEmailProvider::class);
        $this->app->bind(SmsChannelProvider::class, TwilioSmsProvider::class);
    }

    public function boot(): void
    {
        // No-op for now.  Observers and additional placeholder registrations
        // can be added here once tag integration is wired.
    }
}
