Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| Component | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHtml | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| build | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\Codex\Contract; |
| 5 | |
| 6 | use Stringable; |
| 7 | |
| 8 | abstract class Component implements Stringable { |
| 9 | protected function __construct( protected Renderer $renderer ) { |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Get the component's HTML representation. |
| 14 | * |
| 15 | * This method generates the HTML markup for the component, incorporating relevant properties |
| 16 | * and any additional attributes. The component is structured using appropriate HTML elements |
| 17 | * as defined by the implementation. |
| 18 | * |
| 19 | * @since 0.8.0 |
| 20 | * @return string The generated HTML string for the component. |
| 21 | */ |
| 22 | public function getHtml(): string { |
| 23 | return $this->renderer->render( $this ); |
| 24 | } |
| 25 | |
| 26 | public function __toString(): string { |
| 27 | return $this->getHtml(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Backwards compatibility for the pre-0.8 API. |
| 32 | * @deprecated |
| 33 | * @return static |
| 34 | */ |
| 35 | public function build() { |
| 36 | return $this; |
| 37 | } |
| 38 | } |