2023-08-15 21:39:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Activity\Notifications\MessageParts;
|
|
|
|
|
|
|
|
use Illuminate\Contracts\Support\Htmlable;
|
2023-09-02 22:11:42 +08:00
|
|
|
use Stringable;
|
2023-08-15 21:39:39 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A bullet point list of content, where the keys of the given list array
|
|
|
|
* are bolded header elements, and the values follow.
|
|
|
|
*/
|
2023-09-02 22:11:42 +08:00
|
|
|
class ListMessageLine implements Htmlable, Stringable
|
2023-08-15 21:39:39 +08:00
|
|
|
{
|
|
|
|
public function __construct(
|
|
|
|
protected array $list
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toHtml(): string
|
|
|
|
{
|
|
|
|
$list = [];
|
|
|
|
foreach ($this->list as $header => $content) {
|
|
|
|
$list[] = '<strong>' . e($header) . '</strong> ' . e($content);
|
|
|
|
}
|
|
|
|
return implode("<br>\n", $list);
|
|
|
|
}
|
2023-09-02 22:11:42 +08:00
|
|
|
|
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
$list = [];
|
|
|
|
foreach ($this->list as $header => $content) {
|
|
|
|
$list[] = $header . ' ' . $content;
|
|
|
|
}
|
|
|
|
return implode("\n", $list);
|
|
|
|
}
|
2023-08-15 21:39:39 +08:00
|
|
|
}
|