forms/inputs/Label.php
2024-05-28 17:10:06 +03:00

58 lines
1.0 KiB
PHP
Executable File

<?php
namespace itguild\forms\form\inputs;
use itguild\forms\form\traits\CreateParams;
class Label extends BaseInput
{
use CreateParams;
private string $title;
private array $paramsArray;
/**
* @param string $title
* @param array $paramsArray
*/
public function __construct(string $title, array $paramsArray = [])
{
$this->title = $title;
$this->paramsArray = $paramsArray;
}
/**
* @return $this
*/
public function create(): self
{
$paramsString = $this->createParams($this->paramsArray);
$this->html = "<label $paramsString >$this->title</label>";
return $this;
}
/**
* @return string
*/
public function getHtml(): string
{
return $this->html;
}
/**
* @param string $title
* @param array $paramsArray
* @return void
*/
public static function build(string $title, array $paramsArray = [])
{
$label = new self($title, $paramsArray);
$label->create()->render();
}
}