. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Report; use function htmlspecialchars_decode; use function str_replace; use function strip_tags; use function strpos; use function trim; /** * Class ReportBaseFootnote */ class ReportBaseFootnote extends ReportBaseElement { /** * The name of the style for this element * * @var string */ public $styleName = ''; /** * Numbers for the links * * @var int */ public $num; /** * The text that will be printed with the number * * @var string */ public $numText = ''; /** * Remaining width of a cell * * @var float User unit (points) */ public $wrapWidthRemaining; /** * Original width of a cell * * @var float User unit (points) */ public $wrapWidthCell; /** @var string A link */ public $addlink; /** * Createa an element. * * @param string $style */ public function __construct($style = '') { $this->text = ''; if (!empty($style)) { $this->styleName = $style; } else { $this->styleName = 'footnote'; } } /** * Add text. * * @param string $t * * @return void */ public function addText(string $t): void { $t = trim($t, "\r\n\t"); $t = str_replace([ '
', ' ', ], [ "\n", ' ', ], $t); $t = strip_tags($t); $t = htmlspecialchars_decode($t); $this->text .= $t; } /** * Set the width to wrap text. * * @param float $wrapwidth * @param float $cellwidth * * @return float */ public function setWrapWidth(float $wrapwidth, float $cellwidth): float { $this->wrapWidthCell = $cellwidth; if (strpos($this->numText, "\n") !== false) { $this->wrapWidthRemaining = $cellwidth; } else { $this->wrapWidthRemaining = $wrapwidth; } return $this->wrapWidthRemaining; } /** * Set the number. * * @param int $n * * @return void */ public function setNum(int $n): void { $this->num = $n; $this->numText = $n . ' '; } /** * Add a link. * * @param string $a * * @return void */ public function setAddlink(string $a) { $this->addlink = $a; } }