<?php
/**
 * Footer payment method labels (architecture shell — no card brand assets yet).
 *
 * @package Kutby
 * @since   2.7.0
 */

declare(strict_types=1);

namespace Kutby\Footer\Components;

use Kutby\Footer\Contracts\FooterComponentInterface;
use Kutby\Footer\Support\FooterContext;

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

/**
 * Class PaymentIcons
 */
final class PaymentIcons implements FooterComponentInterface {

	/**
	 * Default method labels (text-only until brand SVGs exist).
	 *
	 * @var array<int, string>
	 */
	private const DEFAULT_METHODS = array( 'Visa', 'Mastercard', 'Mada' );

	/**
	 * {@inheritdoc}
	 */
	public static function render( FooterContext $ctx, array $args = array() ): void {
		if ( ! $ctx->bool( 'show_payment' ) ) {
			return;
		}

		/**
		 * Filter payment method labels shown in the footer.
		 *
		 * @since 2.7.0
		 *
		 * @param array<int, string> $methods Labels.
		 */
		$methods = apply_filters( 'kutby_footer_payment_methods', self::DEFAULT_METHODS );
		if ( ! is_array( $methods ) || empty( $methods ) ) {
			return;
		}
		?>
		<ul class="kutby-footer-payment" aria-label="طرق الدفع">
			<?php foreach ( $methods as $method ) : ?>
				<?php
				$label = is_string( $method ) ? trim( $method ) : '';
				if ( '' === $label ) {
					continue;
				}
				?>
				<li class="kutby-footer-payment__item">
					<span class="kutby-footer-payment__label"><?php echo esc_html( $label ); ?></span>
				</li>
			<?php endforeach; ?>
		</ul>
		<?php
	}
}
