. */ namespace SP\Core\Messages; use SP\Domain\Core\Messages\FormatterInterface; /** * Class NoticeMessage * * @package SP\Core\Messages */ final class NotificationMessage extends MessageBase { /** * Componer un mensaje en formato HTML */ public function composeHtml(): string { $formatter = new HtmlFormatter(); $message = '
'; if ($this->title) { $message .= '

' . $this->title . '

'; } if (count($this->description) !== 0) { $message .= '
' . $this->getDescription($formatter) . '
'; } if (count($this->footer) !== 0) { $message .= ''; } $message .= '
'; return $message; } public function getDescription( FormatterInterface $formatter, bool $translate ): string { return $formatter->formatDescription($this->description, $translate); } /** * Componer un mensaje en formato texto */ public function composeText(string $delimiter = PHP_EOL): string { $parts = []; if ($this->title) { $parts[] = $this->title; } if (count($this->description) !== 0) { $parts[] = implode($delimiter, $this->description); } if (count($this->footer) !== 0) { $parts[] = implode($delimiter, $this->footer); } return implode($delimiter, $parts); } }