Completed
Push — styling ( 65b228 )
by Jeroen De
04:06
created

OutputFacade::newFromParserOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Maps\Presentation;
4
5
use OutputPage;
6
use ParserOutput;
7
8
class OutputFacade {
9
10
	/**
11
	 * @var OutputPage
12
	 */
13
	private $outputPage;
14
15
	/**
16
	 * @var ParserOutput
17
	 */
18
	private $parserOutput;
19
20
	public static function newFromOutputPage( OutputPage $outputPage ) {
21
		$instance = new self();
22
		$instance->outputPage = $outputPage;
23
		return $instance;
24
	}
25
26 1
	public static function newFromParserOutput( ParserOutput $parserOutput ) {
27 1
		$instance = new self();
28 1
		$instance->parserOutput = $parserOutput;
29 1
		return $instance;
30
	}
31
32 1
	public function addHtml( string $html ) {
33 1
		if ( $this->outputPage !== null ) {
34
			$this->outputPage->addHTML( $html );
35
		}
36
37 1
		if ( $this->parserOutput !== null ) {
38 1
			$this->parserOutput->setText( $this->parserOutput->getRawText() . $html );
39
		}
40 1
	}
41
42 1
	public function addModules( string ...$modules ) {
43 1
		if ( $this->outputPage !== null ) {
44
			$this->outputPage->addModules( $modules );
45
		}
46
47 1
		if ( $this->parserOutput !== null ) {
48 1
			$this->parserOutput->addModules( $modules );
49
		}
50 1
	}
51
52 1
	public function addHeadItem( string $name, string $html ) {
53 1
		if ( $this->outputPage !== null ) {
54
			$this->outputPage->addHeadItem( $name, $html );
55
		}
56
57 1
		if ( $this->parserOutput !== null ) {
58 1
			$this->parserOutput->addHeadItem( $html, $name );
59
		}
60 1
	}
61
62
}
63