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

MapHtmlBuilder::getMapHTML()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 15
cts 15
cp 1
rs 9.536
c 0
b 0
f 0
cc 3
nc 4
nop 3
crap 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