<?php

namespace Planaday\Html;

use Planaday\Html\Tags\TagController;
use Planaday\Platform\PlatformAbstraction\LocalizationController;
use Planaday\Utility\DateAndTimeUtility;
use Planaday\Utility\Debug\Log\Logging;
use Planaday\Utility\Timer\TimerFactory;

class HtmlParserFactory {
	use Logging;

	public function __construct(
		protected TagController $tagController,
		protected DateAndTimeUtility $dateAndTimeUtility,
		protected TimerFactory $timerFactory,
		protected LocalizationController $localizationController
	) {}

	/**
	 * @param array<mixed>|null $context
	 *
	 * @return HtmlParser
	 */
	public function getParser(?array $context = null):HtmlParser {
		$parser = new HtmlParser($this->tagController, $this->dateAndTimeUtility, $this->timerFactory, $this->localizationController);
		if ($this->logger !== null) $parser->setLogger($this->logger);
		$parser->setParserContext($context);
		return $parser;
	}
}