Completed
Push — wtf-is-going-on ( c96be6 )
by Jeroen De
08:59
created

GeoJsonPageOutput::getNewPageHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 9
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Presentation;
6
7
use Html;
8
9
class GeoJsonPageOutput {
10
11
	private $json;
12
13
	public static function forNewPage(): self {
14
		return new self( null );
15
	}
16
17
	public static function forExistingPage( string $mapJson ): self {
18
		return new self( $mapJson );
19
	}
20
21
	private function __construct( ?string $json ) {
22
		$this->json = $json;
23
	}
24
25
	public function addToParserOutput( \ParserOutput $parserOutput ) {
26
		$parserOutput->setText(  $this->getHtml() );
27
		$parserOutput->addModules( $this->getResourceModules() );
28
	}
29
30
	public function addToOutputPage( \OutputPage $output ) {
31
		$output->addHTML(  $this->getHtml() );
32
		$output->addModules( $this->getResourceModules() );
33
	}
34
35
	private function getResourceModules(): array {
36
		return [
37
			'ext.maps.leaflet.loader'
38
		];
39
	}
40
41
	private function getHtml(): string {
42
		return '<div id="GeoJsonMap" class="maps-leaflet" style="height: 400px; width: 800px"></div>';
43
	}
44
45
}
46