]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/MessageParts/LinkedMailMessageLine.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Activity / Notifications / MessageParts / LinkedMailMessageLine.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\MessageParts;
4
5 use Illuminate\Contracts\Support\Htmlable;
6 use Stringable;
7
8 /**
9  * A line of text with linked text included, intended for use
10  * in MailMessages. The line should have a ':link' placeholder for
11  * where the link should be inserted within the line.
12  */
13 class LinkedMailMessageLine implements Htmlable, Stringable
14 {
15     public function __construct(
16         protected string $url,
17         protected string $line,
18         protected string $linkText,
19     ) {
20     }
21
22     public function toHtml(): string
23     {
24         $link = '<a href="' . e($this->url) . '">' . e($this->linkText) . '</a>';
25         return str_replace(':link', $link, e($this->line));
26     }
27
28     public function __toString(): string
29     {
30         $link = "{$this->linkText} ({$this->url})";
31         return str_replace(':link', $link, $this->line);
32     }
33 }