Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
15 | public function findClosest(CoordinateCollectionInterface $collection) |
||
16 | { |
||
17 | $geotools = new Geotools(); |
||
18 | $match = null; |
||
19 | $matchDistance = null; |
||
20 | |||
21 | foreach ($collection as $coordinate) { |
||
|
|||
22 | $distance = $geotools->distance()->setFrom($this)->setTo($coordinate); |
||
23 | $flatDistance = $distance->flat(); |
||
24 | if ($matchDistance === null || $flatDistance < $matchDistance) { |
||
25 | $match = $coordinate; |
||
26 | $matchDistance = $flatDistance; |
||
27 | } |
||
28 | } |
||
29 | |||
30 | return $match; |
||
31 | } |
||
32 | } |
||
33 |