CargoFormat   A
last analyzed

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\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