Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WikifunctionsPFragment | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| newFromLiteral | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * WikiLambda extension Parsoid fragment our parser function |
| 5 | * |
| 6 | * @file |
| 7 | * @ingroup Extensions |
| 8 | * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt |
| 9 | * @license MIT |
| 10 | */ |
| 11 | |
| 12 | namespace MediaWiki\Extension\WikiLambda\ParserFunction; |
| 13 | |
| 14 | use Wikimedia\Parsoid\Fragments\LiteralStringPFragment; |
| 15 | use Wikimedia\Parsoid\Fragments\PFragment; |
| 16 | use Wikimedia\Parsoid\Fragments\WikitextPFragment; |
| 17 | |
| 18 | class WikifunctionsPFragment { |
| 19 | /** |
| 20 | * Static method to return a PFragment instance given its content: |
| 21 | * * When the value is an empty string, return WikitextPFragment, which is |
| 22 | * able to produce a span with empty content |
| 23 | * * When the value is a non-empty string, return a LiteralStringPFragment |
| 24 | * |
| 25 | * @param string $value |
| 26 | * @return PFragment |
| 27 | */ |
| 28 | public static function newFromLiteral( string $value = '' ): PFragment { |
| 29 | if ( $value !== '' ) { |
| 30 | return LiteralStringPFragment::newFromLiteral( $value, null ); |
| 31 | } |
| 32 | return WikitextPFragment::newFromWt( '', null ); |
| 33 | } |
| 34 | } |