Completed
Push — master ( 88c9eb...e2ac37 )
by Jeroen De
03:05
created

WikitextParser::wikitextToHtml()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Presentation;
6
7
use Parser;
8
use ParserOptions;
9
10
class WikitextParser {
11
12
	private $parser;
13
14 20
	public function __construct( Parser $parser ) {
15 20
		$this->parser = $parser;
16 20
	}
17
18 19
	public function wikitextToHtml( string $text ): string {
19 19
		if ( trim( $text ) === '' ) {
20 14
			return '';
21
		}
22
23 8
		return $this->parser->parse(
24 8
			$text,
25 8
			$this->parser->getTitle(),
26 8
			new ParserOptions()
27 8
		)->getText();
28
	}
29
30
}