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