CargoFormat::display()   A
last analyzed

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\MapsFactory;
9
10
class CargoFormat extends CargoDisplayFormat {
11
12
	private $parserOutput;
13
14
	public function __construct( \ParserOutput $parserOutput ) {
15
		parent::__construct( $parserOutput );
16
		$this->parserOutput = $parserOutput;
17
	}
18
19
	public static function allowedParameters() {
20
		return [
21
			'height' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-heightparam' )->parse() ],
22
			'width' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-widthparam' )->parse() ],
23
			'icon' => [ 'type' => 'string' ],
24
			'zoom' => [ 'type' => 'int' ]
25
		];
26
	}
27
28
	public function display( array $valuesTable, array $formattedValuesTable, array $fieldDescriptions, array $displayParams ) {
29
		$mapOutput = $this->getResultBuilder()->buildOutputFromCargoData(
30
			$valuesTable,
31
			$formattedValuesTable,
32
			$fieldDescriptions,
33
			$displayParams
34
		);
35
36
		$this->parserOutput->addHeadItem( $mapOutput->getHeadItems() );
37
		$this->parserOutput->addModules( $mapOutput->getResourceModules() );
38
39
		return $mapOutput->getHtml();
40
	}
41
42
	private function getResultBuilder(): CargoOutputBuilder {
43
		return MapsFactory::globalInstance()->newCargoOutputBuilder();
44
	}
45
46
}
47