Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| ZHTMLFragment | |
0.00% |
0 / 17 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDefinition | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| isValid | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getZValue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WikiLambda ZHTMLFragment (Z89) |
| 4 | * |
| 5 | * @file |
| 6 | * @ingroup Extensions |
| 7 | * @copyright 2024 – Abstract Wikipedia team; see AUTHORS.txt |
| 8 | * @license MIT |
| 9 | */ |
| 10 | |
| 11 | namespace MediaWiki\Extension\WikiLambda\ZObjects; |
| 12 | |
| 13 | use MediaWiki\Extension\WikiLambda\Registry\ZTypeRegistry; |
| 14 | |
| 15 | class ZHTMLFragment extends ZObject { |
| 16 | |
| 17 | /** |
| 18 | * Construct a ZHTMLFragment instance (Z89) |
| 19 | * |
| 20 | * @param string $html |
| 21 | */ |
| 22 | public function __construct( $html = '' ) { |
| 23 | $this->data[ ZTypeRegistry::Z_HTML_FRAGMENT_VALUE ] = $html; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @inheritDoc |
| 28 | */ |
| 29 | public static function getDefinition(): array { |
| 30 | return [ |
| 31 | 'type' => [ |
| 32 | 'type' => ZTypeRegistry::Z_REFERENCE, |
| 33 | 'value' => ZTypeRegistry::Z_HTML_FRAGMENT, |
| 34 | ], |
| 35 | 'keys' => [ |
| 36 | ZTypeRegistry::Z_HTML_FRAGMENT_VALUE => [ |
| 37 | 'type' => ZTypeRegistry::BUILTIN_STRING, |
| 38 | 'default' => '' |
| 39 | ], |
| 40 | ], |
| 41 | ]; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @inheritDoc |
| 46 | */ |
| 47 | public function isValid(): bool { |
| 48 | if ( !is_string( $this->data[ ZTypeRegistry::Z_HTML_FRAGMENT_VALUE ] ) ) { |
| 49 | return false; |
| 50 | } |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Get the HTML fragment value |
| 56 | * |
| 57 | * @return string |
| 58 | */ |
| 59 | public function getZValue() { |
| 60 | return $this->data[ ZTypeRegistry::Z_HTML_FRAGMENT_VALUE ]; |
| 61 | } |
| 62 | } |