Completed
Push — newparam ( 9f04a0...72433c )
by Jeroen De
04:14 queued 02:51
created

MapHtmlBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
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 28
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

1 Method

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