1 | <?php |
||
5 | class HtmlElement |
||
6 | { |
||
7 | /** @var string */ |
||
8 | protected $element; |
||
9 | |||
10 | /** @var \Spatie\HtmlElement\Attributes */ |
||
11 | protected $attributes; |
||
12 | |||
13 | /** @var string */ |
||
14 | protected $contents; |
||
15 | |||
16 | /** |
||
17 | * @link https://github.com/spatie/html-element#examples |
||
18 | * |
||
19 | * el('p'); <p></p> |
||
20 | * el('p', 'Hello!') <p>Hello!</p> |
||
21 | * el('p#intro', 'Hello!') <p id="intro">Hello!</p> |
||
22 | * el('p', ['id' => 'intro'], 'Hello!') <p id="intro">Hello!</p> |
||
23 | * |
||
24 | * |
||
25 | * @param string $tag The html element tag. |
||
26 | * @param array|string $attributes When only two arguments are passed, the second parameter |
||
27 | * represents the content instead of the attribute. |
||
28 | * @param array|string $contents Contents can be passed in as a string or an array which |
||
29 | * will be concatenated as siblings. |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | public static function render(string $tag, $attributes = null, $contents = null) : string |
||
37 | |||
38 | protected function __construct(...$arguments) |
||
48 | |||
49 | protected function parseArguments($arguments) |
||
62 | |||
63 | protected function parseContents($contents) |
||
67 | |||
68 | protected function parseAbbreviation(string $abbreviation) |
||
80 | |||
81 | protected function parseAttributes(array $attributes) |
||
85 | |||
86 | protected function renderTag() : string |
||
90 | } |
||
91 |