Completed
Push — master ( 4bfc28...46a6ac )
by Jeroen De
22s queued 10s
created

TemplatedPopup::getWikiText()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\SemanticMW;
6
7
use DataValues\Geo\Values\LatLongValue;
8
9
class TemplatedPopup {
10
11
	private $templateName;
12
	private $extraParameter;
13
14 2
	public function __construct( string $templateName, string $extraParameter ) {
15 2
		$this->templateName = $templateName;
16 2
		$this->extraParameter = $extraParameter;
17 2
	}
18
19 2
	public function getWikiText( string $title, LatLongValue $latLong, array $properties ): string {
20
		$segments = [
21 2
			$this->templateName,
22 2
			'title=' . $title,
23 2
			'latitude=' . $latLong->getLatitude(),
24 2
			'longitude=' . $latLong->getLongitude(),
25 2
			'userparam=' . $this->extraParameter
26
		];
27
28 2
		foreach ( $properties as $name => $value ) {
29 1
			$segments[] = $name . '=' . $value;
30 1
			$segments[] = $value;
31
		}
32
33 2
		return '{{' . implode( '|', $segments ) . '}}';
34
	}
35
36
}
37