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

MapHtmlBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 34
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMapHTML() 0 30 3
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Map;
6
7
use FormatJson;
8
use Html;
9
10
class MapHtmlBuilder {
11
12 29
	public function getMapHTML( array $json, string $mapId, string $serviceName ): string {
13 29
		if ( is_int( $json['height'] ) ) {
14 29
			$json['height'] = (string)$json['height'] . 'px';
15
		}
16
17 29
		if ( is_int( $json['width'] ) ) {
18 1
			$json['width'] = (string)$json['width'] . 'px';
19
		}
20
21 29
		return Html::rawElement(
22 29
			'div',
23
			[
24 29
				'id' => $mapId,
25 29
				'style' => "width: {$json['width']}; height: {$json['height']}; background-color: #eeeeee; overflow: hidden;",
26 29
				'class' => 'maps-map maps-' . $serviceName
27
			],
28 29
			Html::element(
29 29
				'div',
30
				[
31 29
					'class' => 'maps-loading-message'
32
				],
33 29
				wfMessage( 'maps-loading-map' )->inContentLanguage()->text()
34
			)
35 29
			. Html::element(
36 29
				'div',
37 29
				[ 'style' => 'display:none', 'class' => 'mapdata' ],
38 29
				FormatJson::encode( $json )
39
			)
40
		);
41
	}
42
43
}
44