<?php namespace Inf; use Core\Config; use Helper\Conversion; class Status { private array $statuses; public function add(bool $condition, string $text, int|string|null $timeout = 0, ?string $img = ''): void { if (!$condition) { return; } if (!empty($timeout)) { $text .= ' ещё ' . Conversion::secondsToTimeout($timeout - time()); } $text = "<span style='vertical-align:middle;'>$text</span>"; if (!empty($img)) { $text = '<span><img src="' . Config::img() . DIRECTORY_SEPARATOR . $img . '" alt="' . $text . '" style="vertical-align:middle;"></span> ' . $text; } $this->statuses[] = "<div>$text</div>"; // обёртка для центрирования картинки с текстом } public function print(): void { if (empty($this->statuses)) { return; } echo '<br><div style="font-size: smaller;">' . implode('<br>', $this->statuses) . '</div>'; } }