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

CargoFormat   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 37
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A allowedParameters() 0 8 1
A display() 0 13 1
A getResultBuilder() 0 3 1
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