<?php
/**
 * Available logo variants for shipping method labels.
 *
 * @package DhlPolska\ShippingMethod
 */

namespace DhlPolska\ShippingMethod;

/**
 * Logo variants catalog.
 */
class LogoVariants {

	public const VARIANT_DHL_LOGO            = 'dhl_logo';
	public const VARIANT_POINTS_HORIZONTAL   = 'points_horizontal';
	public const VARIANT_POINTS_HORIZONTAL_2 = 'points_horizontal_2';
	public const VARIANT_LOCKERS_HORIZONTAL  = 'lockers_horizontal';

	/**
	 * @var array<string, string>
	 */
	private const VARIANT_FILE_MAP = [
		self::VARIANT_DHL_LOGO            => 'DHL_Logo.svg',
		self::VARIANT_POINTS_HORIZONTAL   => 'punkty_DHL_poziomo.png',
		self::VARIANT_POINTS_HORIZONTAL_2 => 'punkty_DHL_poziomo2.png',
		self::VARIANT_LOCKERS_HORIZONTAL  => 'automaty_poziomo.png',
	];

	/**
	 * @return string
	 */
	public static function get_default_variant(): string {
		return self::VARIANT_DHL_LOGO;
	}

	/**
	 * @return array<string, string>
	 */
	public static function get_variant_options(): array {
		return [
			self::VARIANT_DHL_LOGO            => __( 'Logo DHL', 'dhl-polska' ),
			self::VARIANT_LOCKERS_HORIZONTAL  => __( 'Logo DHL - doręczenie do Automatów', 'dhl-polska' ),
			self::VARIANT_POINTS_HORIZONTAL_2 => __( 'Logo DHL - doręczenie do punktu POP', 'dhl-polska' ),
			self::VARIANT_POINTS_HORIZONTAL   => __( 'Logo DHL - doręczenie do Automatu DHL BOX lub punktu POP', 'dhl-polska' ),
		];
	}

	/**
	 * @return array<string, string>
	 */
	public static function get_variant_file_map(): array {
		return self::VARIANT_FILE_MAP;
	}

	/**
	 * @param string $logo_variant .
	 *
	 * @return string
	 */
	public static function normalize_variant( string $logo_variant ): string {
		$logo_variant = trim( $logo_variant );

		if ( isset( self::VARIANT_FILE_MAP[ $logo_variant ] ) ) {
			return $logo_variant;
		}

		return self::get_default_variant();
	}

	/**
	 * @param string $logo_variant .
	 *
	 * @return string
	 */
	public static function get_logo_file_for_variant( string $logo_variant ): string {
		$normalized_logo_variant = self::normalize_variant( $logo_variant );

		return self::VARIANT_FILE_MAP[ $normalized_logo_variant ];
	}
}
