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

WikitextParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A wikitextToHtml() 0 11 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
}