<?php
if (!defined('ABSPATH')) exit; // Exit if accessed directly
/**
 * Generic helper functions for the plugin.
 *
 * This class contains static methods that can be called from anywhere.
 *
 * @package    Event_Monster
 * @subpackage Event_Monster/includes
 */
class Event_Monster_Free_Helper {

    /**
     * Get the currency symbol.
     * A perfect example of a helper function.
     *
     * @return string The currency symbol.
     */
    public static function get_currency_symbol() {
        $options = get_option( 'em_options' );
        $currency_code = isset( $options['em_currency_code'] ) ? $options['em_currency_code'] : 'USD';
        // A more robust version would have a lookup table for codes to symbols.
        switch ( $currency_code ) {
            case 'EUR':
                return '€';
            case 'GBP':
                return '£';
            case 'USD':
            default:
                return '$';
        }
    }

    /**
     * Formats a date according to WordPress settings.
     *
     * @param string $date_string The date to format.
     * @return string The formatted date.
     */
    public static function format_date( $date_string ) {
        if ( empty($date_string) ) return '';
        $date_format = get_option( 'date_format' );
        return date_i18n( $date_format, strtotime( $date_string ) );
    }
}