Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| HtmlSnippet | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setContent | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| build | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | /** |
| 5 | * HtmlSnippet.php |
| 6 | * |
| 7 | * This file is part of the Codex design system, the official design system for Wikimedia projects. |
| 8 | * It contains the definition and implementation of the `HtmlSnippet` class, responsible for managing |
| 9 | * the behavior and properties of the corresponding component. |
| 10 | * |
| 11 | * @category Component |
| 12 | * @package Codex\Component |
| 13 | * @since 0.1.0 |
| 14 | * @author Doğu Abaris <abaris@null.net> |
| 15 | * @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later |
| 16 | * @link https://doc.wikimedia.org/codex/main/ Codex Documentation |
| 17 | */ |
| 18 | |
| 19 | namespace Wikimedia\Codex\Component; |
| 20 | |
| 21 | /** |
| 22 | * Wrapper class for raw HTML strings. |
| 23 | * |
| 24 | * @category Component |
| 25 | * @package Codex\Component |
| 26 | * @since 0.1.0 |
| 27 | * @author Doğu Abaris <abaris@null.net> |
| 28 | * @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later |
| 29 | * @link https://doc.wikimedia.org/codex/main/ Codex Documentation |
| 30 | */ |
| 31 | class HtmlSnippet { |
| 32 | |
| 33 | /** |
| 34 | * The safe HTML content to be rendered. |
| 35 | */ |
| 36 | private string $content; |
| 37 | |
| 38 | /** |
| 39 | * Constructor for the HtmlSnippet component. |
| 40 | * |
| 41 | * Initializes an instance of HtmlSnippet with the specified content and attributes. |
| 42 | * |
| 43 | * @param string $content The safe HTML content to be rendered. |
| 44 | * @param-taint $content exec_html Callers are responsible for escaping. |
| 45 | */ |
| 46 | public function __construct( string $content ) { |
| 47 | $this->content = $content; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get the raw HTML content. |
| 52 | * |
| 53 | * This method returns the raw HTML content for rendering. |
| 54 | * |
| 55 | * @since 0.1.0 |
| 56 | * @return string The raw HTML content. |
| 57 | */ |
| 58 | public function getContent(): string { |
| 59 | return $this->content; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Backwards compatibility for the pre-0.8.0 API. |
| 64 | * @deprecated |
| 65 | * @param string $content |
| 66 | * @return HtmlSnippet |
| 67 | */ |
| 68 | public function setContent( string $content ): self { |
| 69 | $this->content = $content; |
| 70 | return $this; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Backwards compatibility for the pre-0.8.0 API. |
| 75 | * @deprecated |
| 76 | * @return HtmlSnippet |
| 77 | */ |
| 78 | public function build(): self { |
| 79 | return $this; |
| 80 | } |
| 81 | } |