Completed
Pull Request — master (#168)
by Jeroen De
02:05
created

PrecisionDetector::detectPrecision()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace DataValues\Geo\PackagePrivate;
6
7
use DataValues\Geo\Values\LatLongValue;
8
9
abstract class PrecisionDetector {
10
11
	public function detectPrecision( LatLongValue $latLong ): Precision {
12
		return new Precision(
13
			min(
14
				$this->detectDegreePrecision( $latLong->getLatitude() ),
15
				$this->detectDegreePrecision( $latLong->getLongitude() )
16
			)
17
		);
18
	}
19
20
	abstract protected function detectDegreePrecision( float $degree ): float;
21
22
}
23