<?php
/**
 * BookiFlex Onboarding Extension
 *
 * @package    BookiFlex
 * @subpackage Onboarding
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Extensions\Onboarding\ValueObject;

defined( 'ABSPATH' ) || exit;

/**
 * Currency Value Object
 *
 * Represents a currency option with ISO 4217 code, display label, and symbol.
 *
 * @package BookiFlex\Extensions\Onboarding\ValueObject
 * @since   1.0.0
 */
class Currency
{
    /**
     * Currency constructor
     *
     * @param string $value  ISO 4217 currency code (e.g., USD, EUR, RUB)
     * @param string $label  Display label (e.g., "USD - US Dollar")
     * @param string $symbol Currency symbol (e.g., $, €, ₽)
     *
     * @throws \InvalidArgumentException If currency code is not 3 characters
     */
    public function __construct(
        public readonly string $value,
        public readonly string $label,
        public readonly string $symbol,
    ) {
        if (strlen($this->value) !== 3) {
            throw new \InvalidArgumentException('Currency code must be 3 characters (ISO 4217)');
        }
    }

    /**
     * Convert to array representation
     *
     * @return array{value: string, label: string, symbol: string}
     */
    public function toArray(): array
    {
        return [
            'value' => $this->value,
            'label' => $this->label,
            'symbol' => $this->symbol,
        ];
    }
}
