1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DataValues\Geo\PackagePrivate; |
4
|
|
|
|
5
|
|
|
use DataValues\Geo\Parsers\DdCoordinateParser; |
6
|
|
|
use DataValues\Geo\Parsers\DmCoordinateParser; |
7
|
|
|
use DataValues\Geo\Parsers\DmsCoordinateParser; |
8
|
|
|
use DataValues\Geo\Parsers\FloatCoordinateParser; |
9
|
|
|
use ValueParsers\ParseException; |
10
|
|
|
use ValueParsers\ParserOptions; |
11
|
|
|
|
12
|
|
|
class LatLongPrecisionParser { |
13
|
|
|
|
14
|
|
|
private $options; |
15
|
|
|
private $parsers; |
16
|
|
|
|
17
|
119 |
|
public function __construct( ParserOptions $options = null ) { |
18
|
119 |
|
$this->options = $options; |
19
|
119 |
|
} |
20
|
|
|
|
21
|
119 |
|
public function parse( string $coordinate ): LatLongPrecision { |
22
|
119 |
|
foreach ( $this->getParsers() as $parser ) { |
23
|
|
|
try { |
24
|
119 |
|
$latLongPrecision = $parser->parse( $coordinate ); |
25
|
86 |
|
} catch ( ParseException $parseException ) { |
|
|
|
|
26
|
86 |
|
continue; |
27
|
|
|
} |
28
|
|
|
|
29
|
117 |
|
return $latLongPrecision; |
30
|
|
|
} |
31
|
|
|
|
32
|
2 |
|
throw new ParseException( |
33
|
2 |
|
'The format of the coordinate could not be determined.', |
34
|
|
|
$coordinate |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return PrecisionParser[] |
40
|
|
|
*/ |
41
|
119 |
|
private function getParsers(): iterable { |
42
|
119 |
|
if ( $this->parsers === null ) { |
43
|
119 |
|
$this->parsers = new \CachingIterator( $this->getNewParsers(), \CachingIterator::FULL_CACHE ); |
44
|
|
|
} |
45
|
|
|
|
46
|
119 |
|
return $this->parsers; |
47
|
|
|
} |
48
|
|
|
|
49
|
119 |
|
private function getNewParsers(): \Generator { |
50
|
119 |
|
yield new PrecisionParser( new FloatCoordinateParser( $this->options ), new FloatPrecisionDetector() ); |
51
|
119 |
|
yield new PrecisionParser( new DmsCoordinateParser( $this->options ), new DmsPrecisionDetector() ); |
52
|
86 |
|
yield new PrecisionParser( new DmCoordinateParser( $this->options ), new DmPrecisionDetector() ); |
53
|
56 |
|
yield new PrecisionParser( new DdCoordinateParser( $this->options ), new FloatPrecisionDetector() ); |
54
|
31 |
|
} |
55
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.