<?php
/**
 * Currency Helper Class
 * 
 * Provides comprehensive currency information and utilities
 * 
 * @package EasyInvoice
 * @subpackage Helpers
 */

namespace EasyInvoice\Helpers;

class CurrencyHelper {
    
    /**
     * Get all available currencies with their codes, symbols, and names
     * 
     * @return array Array of currencies with code as key and array of symbol, name as value
     */
    public static function getCurrencies(): array {
        return [
            'USD' => ['symbol' => '$', 'name' => 'US Dollar'],
            'EUR' => ['symbol' => '€', 'name' => 'Euro'],
            'GBP' => ['symbol' => '£', 'name' => 'British Pound'],
            'JPY' => ['symbol' => '¥', 'name' => 'Japanese Yen'],
            'CAD' => ['symbol' => 'C$', 'name' => 'Canadian Dollar'],
            'AUD' => ['symbol' => 'A$', 'name' => 'Australian Dollar'],
            'CHF' => ['symbol' => 'CHF', 'name' => 'Swiss Franc'],
            'CNY' => ['symbol' => '¥', 'name' => 'Chinese Yuan'],
            'INR' => ['symbol' => '₹', 'name' => 'Indian Rupee'],
            'BRL' => ['symbol' => 'R$', 'name' => 'Brazilian Real'],
            'RUB' => ['symbol' => '₽', 'name' => 'Russian Ruble'],
            'KRW' => ['symbol' => '₩', 'name' => 'South Korean Won'],
            'MXN' => ['symbol' => '$', 'name' => 'Mexican Peso'],
            'SGD' => ['symbol' => 'S$', 'name' => 'Singapore Dollar'],
            'HKD' => ['symbol' => 'HK$', 'name' => 'Hong Kong Dollar'],
            'NOK' => ['symbol' => 'kr', 'name' => 'Norwegian Krone'],
            'SEK' => ['symbol' => 'kr', 'name' => 'Swedish Krona'],
            'DKK' => ['symbol' => 'kr', 'name' => 'Danish Krone'],
            'PLN' => ['symbol' => 'zł', 'name' => 'Polish Złoty'],
            'TRY' => ['symbol' => '₺', 'name' => 'Turkish Lira'],
            'ZAR' => ['symbol' => 'R', 'name' => 'South African Rand'],
            'NZD' => ['symbol' => 'NZ$', 'name' => 'New Zealand Dollar'],
            'THB' => ['symbol' => '฿', 'name' => 'Thai Baht'],
            'MYR' => ['symbol' => 'RM', 'name' => 'Malaysian Ringgit'],
            'IDR' => ['symbol' => 'Rp', 'name' => 'Indonesian Rupiah'],
            'PHP' => ['symbol' => '₱', 'name' => 'Philippine Peso'],
            'ILS' => ['symbol' => '₪', 'name' => 'Israeli Shekel'],
            'AED' => ['symbol' => 'د.إ', 'name' => 'UAE Dirham'],
            'SAR' => ['symbol' => 'ر.س', 'name' => 'Saudi Riyal'],
            'QAR' => ['symbol' => 'ر.ق', 'name' => 'Qatari Riyal'],
            'KWD' => ['symbol' => 'د.ك', 'name' => 'Kuwaiti Dinar'],
            'BHD' => ['symbol' => 'د.ب', 'name' => 'Bahraini Dinar'],
            'OMR' => ['symbol' => 'ر.ع.', 'name' => 'Omani Rial'],
            'JOD' => ['symbol' => 'د.ا', 'name' => 'Jordanian Dinar'],
            'EGP' => ['symbol' => 'E£', 'name' => 'Egyptian Pound'],
            'NGN' => ['symbol' => '₦', 'name' => 'Nigerian Naira'],
            'KES' => ['symbol' => 'KSh', 'name' => 'Kenyan Shilling'],
            'GHS' => ['symbol' => 'GH₵', 'name' => 'Ghanaian Cedi'],
            'UGX' => ['symbol' => 'USh', 'name' => 'Ugandan Shilling'],
            'TZS' => ['symbol' => 'TSh', 'name' => 'Tanzanian Shilling'],
            'MAD' => ['symbol' => 'د.م.', 'name' => 'Moroccan Dirham'],
            'TND' => ['symbol' => 'د.ت', 'name' => 'Tunisian Dinar'],
            'DZD' => ['symbol' => 'د.ج', 'name' => 'Algerian Dinar'],
            'LYD' => ['symbol' => 'ل.د', 'name' => 'Libyan Dinar'],
            'SDG' => ['symbol' => 'ج.س.', 'name' => 'Sudanese Pound'],
            'ETB' => ['symbol' => 'Br', 'name' => 'Ethiopian Birr'],
            'SOS' => ['symbol' => 'S', 'name' => 'Somali Shilling'],
            'DJF' => ['symbol' => 'Fdj', 'name' => 'Djiboutian Franc'],
            'KMF' => ['symbol' => 'CF', 'name' => 'Comorian Franc'],
            'MUR' => ['symbol' => '₨', 'name' => 'Mauritian Rupee'],
            'SCR' => ['symbol' => '₨', 'name' => 'Seychellois Rupee'],
            'MVR' => ['symbol' => 'MVR', 'name' => 'Maldivian Rufiyaa'],
            'LKR' => ['symbol' => 'Rs', 'name' => 'Sri Lankan Rupee'],
            'BDT' => ['symbol' => '৳', 'name' => 'Bangladeshi Taka'],
            'NPR' => ['symbol' => '₨', 'name' => 'Nepalese Rupee'],
            'PKR' => ['symbol' => '₨', 'name' => 'Pakistani Rupee'],
            'AFN' => ['symbol' => '؋', 'name' => 'Afghan Afghani'],
            'IRR' => ['symbol' => '﷼', 'name' => 'Iranian Rial'],
            'IQD' => ['symbol' => 'ع.د', 'name' => 'Iraqi Dinar'],
            'SYP' => ['symbol' => 'ل.س', 'name' => 'Syrian Pound'],
            'LBP' => ['symbol' => 'ل.ل', 'name' => 'Lebanese Pound'],
            'JMD' => ['symbol' => 'J$', 'name' => 'Jamaican Dollar'],
            'TTD' => ['symbol' => 'TT$', 'name' => 'Trinidad and Tobago Dollar'],
            'BBD' => ['symbol' => 'Bds$', 'name' => 'Barbadian Dollar'],
            'XCD' => ['symbol' => 'EC$', 'name' => 'East Caribbean Dollar'],
            'BZD' => ['symbol' => 'BZ$', 'name' => 'Belize Dollar'],
            'GTQ' => ['symbol' => 'Q', 'name' => 'Guatemalan Quetzal'],
            'HNL' => ['symbol' => 'L', 'name' => 'Honduran Lempira'],
            'NIO' => ['symbol' => 'C$', 'name' => 'Nicaraguan Córdoba'],
            'CRC' => ['symbol' => '₡', 'name' => 'Costa Rican Colón'],
            'PAB' => ['symbol' => 'B/.', 'name' => 'Panamanian Balboa'],
            'DOP' => ['symbol' => 'RD$', 'name' => 'Dominican Peso'],
            'HTG' => ['symbol' => 'G', 'name' => 'Haitian Gourde'],
            'CUP' => ['symbol' => '$', 'name' => 'Cuban Peso'],
            'ARS' => ['symbol' => '$', 'name' => 'Argentine Peso'],
            'CLP' => ['symbol' => '$', 'name' => 'Chilean Peso'],
            'COP' => ['symbol' => '$', 'name' => 'Colombian Peso'],
            'PEN' => ['symbol' => 'S/', 'name' => 'Peruvian Sol'],
            'BOB' => ['symbol' => 'Bs', 'name' => 'Bolivian Boliviano'],
            'PYG' => ['symbol' => '₲', 'name' => 'Paraguayan Guaraní'],
            'UYU' => ['symbol' => '$', 'name' => 'Uruguayan Peso'],
            'VEF' => ['symbol' => 'Bs', 'name' => 'Venezuelan Bolívar'],
            'GYD' => ['symbol' => 'G$', 'name' => 'Guyanese Dollar'],
            'SRD' => ['symbol' => '$', 'name' => 'Surinamese Dollar'],
            'FJD' => ['symbol' => 'FJ$', 'name' => 'Fijian Dollar'],
            'WST' => ['symbol' => 'T', 'name' => 'Samoan Tālā'],
            'TOP' => ['symbol' => 'T$', 'name' => 'Tongan Paʻanga'],
            'VUV' => ['symbol' => 'VT', 'name' => 'Vanuatu Vatu'],
            'PGK' => ['symbol' => 'K', 'name' => 'Papua New Guinean Kina'],
            'SBD' => ['symbol' => 'SI$', 'name' => 'Solomon Islands Dollar'],
            'KID' => ['symbol' => '$', 'name' => 'Kiribati Dollar'],
            'TVD' => ['symbol' => '$', 'name' => 'Tuvaluan Dollar'],
            'XPF' => ['symbol' => '₣', 'name' => 'CFP Franc'],
            'NOK' => ['symbol' => 'kr', 'name' => 'Norwegian Krone'],
            'SEK' => ['symbol' => 'kr', 'name' => 'Swedish Krona'],
            'DKK' => ['symbol' => 'kr', 'name' => 'Danish Krone'],
            'ISK' => ['symbol' => 'kr', 'name' => 'Icelandic Króna'],
            'CZK' => ['symbol' => 'Kč', 'name' => 'Czech Koruna'],
            'HUF' => ['symbol' => 'Ft', 'name' => 'Hungarian Forint'],
            'RON' => ['symbol' => 'lei', 'name' => 'Romanian Leu'],
            'BGN' => ['symbol' => 'лв', 'name' => 'Bulgarian Lev'],
            'HRK' => ['symbol' => 'kn', 'name' => 'Croatian Kuna'],
            'RSD' => ['symbol' => 'дин', 'name' => 'Serbian Dinar'],
            'ALL' => ['symbol' => 'L', 'name' => 'Albanian Lek'],
            'MKD' => ['symbol' => 'ден', 'name' => 'Macedonian Denar'],
            'MDL' => ['symbol' => 'L', 'name' => 'Moldovan Leu'],
            'UAH' => ['symbol' => '₴', 'name' => 'Ukrainian Hryvnia'],
            'BYN' => ['symbol' => 'Br', 'name' => 'Belarusian Ruble'],
            'GEL' => ['symbol' => '₾', 'name' => 'Georgian Lari'],
            'AMD' => ['symbol' => '֏', 'name' => 'Armenian Dram'],
            'AZN' => ['symbol' => '₼', 'name' => 'Azerbaijani Manat'],
            'KZT' => ['symbol' => '₸', 'name' => 'Kazakhstani Tenge'],
            'KGS' => ['symbol' => 'с', 'name' => 'Kyrgyzstani Som'],
            'TJS' => ['symbol' => 'ЅМ', 'name' => 'Tajikistani Somoni'],
            'TMT' => ['symbol' => 'T', 'name' => 'Turkmenistani Manat'],
            'UZS' => ['symbol' => 'so\'m', 'name' => 'Uzbekistani Som'],
            'MNT' => ['symbol' => '₮', 'name' => 'Mongolian Tögrög'],
            'LAK' => ['symbol' => '₭', 'name' => 'Lao Kip'],
            'KHR' => ['symbol' => '៛', 'name' => 'Cambodian Riel'],
            'MMK' => ['symbol' => 'K', 'name' => 'Myanmar Kyat'],
            'VND' => ['symbol' => '₫', 'name' => 'Vietnamese Đồng'],
            'BTN' => ['symbol' => 'Nu.', 'name' => 'Bhutanese Ngultrum'],
            'MOP' => ['symbol' => 'MOP$', 'name' => 'Macanese Pataca'],
            'TWD' => ['symbol' => 'NT$', 'name' => 'New Taiwan Dollar'],
            'HKD' => ['symbol' => 'HK$', 'name' => 'Hong Kong Dollar'],
            'KRW' => ['symbol' => '₩', 'name' => 'South Korean Won'],
            'JPY' => ['symbol' => '¥', 'name' => 'Japanese Yen'],
            'CNY' => ['symbol' => '¥', 'name' => 'Chinese Yuan'],
            'MOP' => ['symbol' => 'MOP$', 'name' => 'Macanese Pataca'],
            'TWD' => ['symbol' => 'NT$', 'name' => 'New Taiwan Dollar'],
            'HKD' => ['symbol' => 'HK$', 'name' => 'Hong Kong Dollar'],
            'KRW' => ['symbol' => '₩', 'name' => 'South Korean Won'],
            'JPY' => ['symbol' => '¥', 'name' => 'Japanese Yen'],
            'CNY' => ['symbol' => '¥', 'name' => 'Chinese Yuan'],
        ];
    }
    
    /**
     * Get currency options for select dropdown
     * 
     * @return array Array of currency options formatted for select dropdown
     */
    public static function getCurrencyOptions(): array {
        $currencies = self::getCurrencies();
        $options = [];
        
        foreach ($currencies as $code => $currency) {
            $options[$code] = sprintf('%s (%s) - %s', $code, $currency['symbol'], $currency['name']);
        }
        
        return $options;
    }
    
    /**
     * Get currency symbol by code
     * 
     * @param string $code Currency code
     * @return string Currency symbol
     */
    public static function getCurrencySymbol(string $code): string {
        $currencies = self::getCurrencies();
        return $currencies[$code]['symbol'] ?? '$';
    }
    
    /**
     * Get currency name by code
     * 
     * @param string $code Currency code
     * @return string Currency name
     */
    public static function getCurrencyName(string $code): string {
        $currencies = self::getCurrencies();
        return $currencies[$code]['name'] ?? 'Unknown Currency';
    }
    
    /**
     * Check if currency code is valid
     * 
     * @param string $code Currency code
     * @return bool True if valid, false otherwise
     */
    public static function isValidCurrency(string $code): bool {
        $currencies = self::getCurrencies();
        return isset($currencies[$code]);
    }
} 