Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
RawHtml
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Epic64\Elem\Elements;
6
7/**
8 * Represents raw HTML content that should not be escaped.
9 *
10 * WARNING: Only use this with trusted content. Using raw HTML with
11 * user-provided input can lead to XSS vulnerabilities.
12 *
13 * @example
14 * ```php
15 * div()(
16 *     raw('<strong>Bold text</strong>'),
17 *     raw($trustedHtmlFromDatabase)
18 * )
19 * ```
20 */
21class RawHtml
22{
23    public function __construct(
24        public readonly string $html
25    ) {}
26
27    public function __toString(): string
28    {
29        return $this->html;
30    }
31}