<?php
/**
 * Footer navigation component.
 *
 * @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 Navigation
 */
final class Navigation implements FooterComponentInterface {

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

		$id    = isset( $args['id'] ) ? (string) $args['id'] : 'kutby-footer-nav';
		$class = isset( $args['class'] ) ? (string) $args['class'] : 'kutby-footer-nav';
		$depth = isset( $args['depth'] ) ? (int) $args['depth'] : 1;
		?>
		<nav
			id="<?php echo esc_attr( $id ); ?>"
			class="<?php echo esc_attr( $class ); ?>"
			aria-label="قائمة الفوتر"
		>
			<?php
			wp_nav_menu(
				array(
					'theme_location' => 'footer',
					'container'      => false,
					'menu_class'     => 'kutby-footer-menu',
					'fallback_cb'    => false,
					'depth'          => $depth,
				)
			);
			?>
		</nav>
		<?php
	}
}
