Passed
Push — GlobeCoordinateParser ( 7d8c3a )
by Jeroen De
02:26
created

DmPrecisionDetector::detectDegreePrecision()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 9.9332
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace DataValues\Geo\PackagePrivate;
6
7
class DmPrecisionDetector extends PrecisionDetector {
8
9
	private $dmsPrecisionDetector;
10
11
	public function __construct() {
12
		$this->dmsPrecisionDetector = new DmsPrecisionDetector();
13
	}
14
15
	public function detectDegreePrecision( float $degree ): float {
16
		$minutes = $degree * 60;
17
		$split = explode( '.', (string)round( $minutes, 6 ) );
18
19
		if ( isset( $split[1] ) ) {
20
			return $this->dmsPrecisionDetector->detectDegreePrecision( $degree );
21
		}
22
23
		return 1 / 60;
24
	}
25
26
}
27