Conditions | 4 |
Paths | 8 |
Total Lines | 38 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | protected function getArray(Location $location): array |
||
28 | { |
||
29 | $properties = array_filter($location->toArray(), function ($value) { |
||
30 | return !empty($value); |
||
31 | }); |
||
32 | |||
33 | unset( |
||
34 | $properties['latitude'], |
||
35 | $properties['longitude'], |
||
36 | $properties['bounds'] |
||
37 | ); |
||
38 | |||
39 | if (0 === count($properties)) { |
||
40 | $properties = null; |
||
41 | } |
||
42 | |||
43 | $lat = 0; |
||
44 | $lon = 0; |
||
45 | if (null !== $coordinates = $location->getCoordinates()) { |
||
46 | $lat = $coordinates->getLatitude(); |
||
47 | $lon = $coordinates->getLongitude(); |
||
48 | } |
||
49 | |||
50 | $array = [ |
||
51 | 'type' => 'Feature', |
||
52 | 'geometry' => [ |
||
53 | 'type' => 'Point', |
||
54 | 'coordinates' => [$lon, $lat], |
||
55 | ], |
||
56 | 'properties' => $properties, |
||
57 | ]; |
||
58 | |||
59 | if (null !== $bounds = $location->getBounds()) { |
||
60 | $array['bounds'] = $bounds->toArray(); |
||
61 | } |
||
62 | |||
63 | return $array; |
||
64 | } |
||
65 | } |
||
66 |