<?php

namespace Licenzo\Services\Integrations;

if (!defined('ABSPATH')) {
    exit;
}

class ProviderAliasService
{
    private const ALIAS_MAP = [
        'woo' => 'woocommerce',
        'wc' => 'woocommerce',
        'woocommerce' => 'woocommerce',
        'manual' => 'manual',
        'stripe' => 'stripe',
        'paypal' => 'paypal',
        'paddle' => 'paddle',
        'lemonsqueezy' => 'lemonsqueezy',
        'surecart' => 'surecart',
        'edd' => 'edd',
    ];

    public static function normalize(string $provider, string $fallback = 'manual'): string
    {
        $normalized = strtolower(trim($provider));

        if ($normalized === '') {
            return $fallback;
        }

        return self::ALIAS_MAP[$normalized] ?? $normalized;
    }

    public static function isWoo(?string $provider): bool
    {
        return self::normalize((string) $provider, '') === 'woocommerce';
    }

    public static function wooAliases(): array
    {
        return ['woo', 'woocommerce'];
    }

    public static function isEdd(?string $provider): bool
    {
        return self::normalize((string) $provider, '') === 'edd';
    }

    public static function eddAliases(): array
    {
        return ['edd'];
    }
}

