Completed
Push — master ( 4d0076...81538e )
by Jeroen De
26s queued 11s
created

CargoFormat::display()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Map\CargoFormat;
6
7
use CargoDisplayFormat;
8
use Maps\Map\CargoFormat\CargoOutputBuilder;
9
use Maps\MapsFactory;
10
11
class CargoFormat extends CargoDisplayFormat {
12
13
	private $parserOutput;
14
15
	public function __construct( \ParserOutput $parserOutput ) {
16
		parent::__construct( $parserOutput );
17
		$this->parserOutput = $parserOutput;
18
	}
19
20
	public static function allowedParameters() {
21
		return [
22
			'height' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-heightparam' )->parse() ],
23
			'width' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-widthparam' )->parse() ],
24
			'icon' => [ 'type' => 'string' ],
25
			'zoom' => [ 'type' => 'int' ]
26
		];
27
	}
28
29
	public function display( array $valuesTable, array $formattedValuesTable, array $fieldDescriptions, array $displayParams ) {
30
		$mapOutput = $this->getResultBuilder()->buildOutputFromCargoData(
31
			$valuesTable,
32
			$formattedValuesTable,
33
			$fieldDescriptions,
34
			$displayParams
35
		);
36
37
		$this->parserOutput->addHeadItem( $mapOutput->getHeadItems() );
38
		$this->parserOutput->addModules( $mapOutput->getResourceModules() );
39
40
		return $mapOutput->getHtml();
41
	}
42
43
	private function getResultBuilder(): CargoOutputBuilder {
44
		return MapsFactory::globalInstance()->newCargoOutputBuilder();
45
	}
46
47
}
48