Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
PartialWikitextParser | n/a |
0 / 0 |
n/a |
0 / 0 |
4 | n/a |
0 / 0 |
|||
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
halfParseWikitext | n/a |
0 / 0 |
n/a |
0 / 0 |
3 |
1 | <?php |
2 | |
3 | namespace Kartographer; |
4 | |
5 | use MediaWiki\Parser\Parser; |
6 | use MediaWiki\Parser\PPFrame; |
7 | |
8 | /** |
9 | * @license MIT |
10 | * @codeCoverageIgnore |
11 | */ |
12 | class PartialWikitextParser { |
13 | |
14 | private Parser $parser; |
15 | private PPFrame $frame; |
16 | |
17 | public function __construct( Parser $parser, PPFrame $frame ) { |
18 | $this->parser = $parser; |
19 | $this->frame = $frame; |
20 | } |
21 | |
22 | /** |
23 | * @param string $wikiText |
24 | * @return string Half-parsed HTML according to {@see Parser::recursiveTagParse} |
25 | */ |
26 | public function halfParseWikitext( string $wikiText ): string { |
27 | // Don't parse trivial alphanumeric-only strings, e.g. counters like "A" or "99". |
28 | if ( $wikiText === '' || ctype_alnum( $wikiText ) ) { |
29 | return $wikiText; |
30 | } |
31 | |
32 | return $this->parser->recursiveTagParse( $wikiText, $this->frame ); |
33 | } |
34 | |
35 | } |