<?php

namespace Planaday\Utility\FormBuilder\LayoutItems;

use Planaday\Utility\FormBuilder\LayoutItem;

class Header implements LayoutItem {
	use BasicLayoutItem;

	public function __construct(
		protected string $text,
		protected int $level = 3
	) {
		if ( $this->level > 6) {
			$this->level = 6;
		} else if ( $this->level < 1) {
			$this->level = 1;
		}
	}

	public function getText(): string {
		return $this->text;
	}

	public function getLevel(): int {
		return $this->level;
	}
	
	public function getImplJson(): array {
		return [
			"type" => 'header',
			"level" => $this->level,
			"text" => $this->text
		];
	}
}