]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/MessageParts/ListMessageLine.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Activity / Notifications / MessageParts / ListMessageLine.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\MessageParts;
4
5 use Illuminate\Contracts\Support\Htmlable;
6 use Stringable;
7
8 /**
9  * A bullet point list of content, where the keys of the given list array
10  * are bolded header elements, and the values follow.
11  */
12 class ListMessageLine implements Htmlable, Stringable
13 {
14     public function __construct(
15         protected array $list
16     ) {
17     }
18
19     public function toHtml(): string
20     {
21         $list = [];
22         foreach ($this->list as $header => $content) {
23             $list[] = '<strong>' . e($header) . '</strong> ' . e($content);
24         }
25         return implode("<br>\n", $list);
26     }
27
28     public function __toString(): string
29     {
30         $list = [];
31         foreach ($this->list as $header => $content) {
32             $list[] = $header . ' ' . $content;
33         }
34         return implode("\n", $list);
35     }
36 }