Conditions | 5 |
Paths | 16 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
30 | public function getCoordinates( |
||
31 | string $street = null, |
||
32 | string $streetNumber = null, |
||
33 | string $city = null, |
||
34 | string $zip = null, |
||
35 | string $country = null |
||
36 | ): array { |
||
37 | if (!empty($country)) { |
||
38 | $country = Intl::getRegionBundle()->getCountryName($country, Language::getInterfaceLanguage()); |
||
39 | } |
||
40 | |||
41 | try { |
||
42 | /** @var Coordinates $coordinates */ |
||
43 | $coordinates = $this->api->getCoordinates( |
||
44 | $street, |
||
45 | $streetNumber, |
||
46 | $city, |
||
47 | $zip, |
||
48 | $country |
||
49 | ); |
||
50 | } catch (Exception $e) { |
||
51 | $coordinates = null; |
||
52 | } |
||
53 | |||
54 | return [ |
||
55 | 'latitude' => ($coordinates instanceof Coordinates) ? $coordinates->getLatitude() : null, |
||
56 | 'longitude' => ($coordinates instanceof Coordinates) ? $coordinates->getLongitude() : null, |
||
57 | ]; |
||
60 |