<?php
namespace PHPFUI;
class IconBase extends \PHPFUI\HTML5Element
{
public function __construct(string $icon, private string $link = '')
{
parent::__construct('i');
$this->addClass($icon);
}
public function getLink() : string
{
return $this->link;
}
public function setLink(string $link) : static
{
$this->link = $link;
return $this;
}
protected function getEnd() : string
{
return $this->link ? '</a>' : '';
}
protected function getStart() : string
{
$output = '';
if ($this->link)
{
$id = $this->getId();
$link = '';
if ('#' != $this->link)
{
$link = "href='{$this->link}' ";
}
$target = $this->getAttribute('target');
if ($target)
{
$target = "target='{$target}' ";
}
$output = "<a {$target}id='{$id}a' {$link}>";
}
$this->deleteAttribute('target');
return $output . $this->getToolTip(parent::getStart() . parent::getBody() . parent::getEnd());
}
}