CoordinateFormatter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 11 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Presentation;
6
7
use DataValues\Geo\Formatters\LatLongFormatter;
8
use DataValues\Geo\Values\LatLongValue;
9
use ValueFormatters\FormatterOptions;
10
11
/**
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class CoordinateFormatter {
16
17
	private const PRECISION_MAP = [
18
		'dms' => 1 / 360000,
19
		'dm' => 1 / 600000,
20
		'dd' => 1 / 1000000,
21
		'float' => 1 / 1000000,
22
	];
23
24 20
	public function format( LatLongValue $latLong, string $format, bool $directional ) {
25 20
		$formatter = new LatLongFormatter( new FormatterOptions(
26
			[
27 20
				LatLongFormatter::OPT_FORMAT => $format,
28 20
				LatLongFormatter::OPT_DIRECTIONAL => $directional,
29 20
				LatLongFormatter::OPT_PRECISION => self::PRECISION_MAP[$format]
30
			]
31
		) );
32
33 20
		return $formatter->format( $latLong );
34
	}
35
36
}
37