<?php
/**
 * Header renderer — presentation only.
 *
 * @package Kutby
 * @since   2.6.0
 */

declare(strict_types=1);

namespace Kutby\Header\Services;

use Kutby\Events\Dispatcher;
use Kutby\Header\Support\HeaderContext;

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

/**
 * Class HeaderRenderer
 */
final class HeaderRenderer {

	/**
	 * Render the active header layout.
	 *
	 * @return void
	 */
	public static function render(): void {
		$manager = new HeaderManager();
		$layout  = $manager->layout();
		$ctx     = HeaderContext::from_request();

		$layout->render( $ctx );

		Dispatcher::emit(
			'header_rendered',
			array(
				'layout' => $layout->id(),
			)
		);
	}
}
