| Conditions | 4 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4.7691 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | 6 | public function parse(\stdClass $object): Geometry |
|
| 15 | { |
||
| 16 | 6 | if ($object->type === 'MultiLineString') { |
|
| 17 | 6 | $object->coordinates = array_values( |
|
| 18 | 6 | array_filter($object->coordinates, fn ($array) => !empty($array)) |
|
| 19 | 3 | ); |
|
| 20 | |||
| 21 | 6 | if (count($object->coordinates) === 1) { |
|
| 22 | $object->type = 'LineString'; |
||
| 23 | $object->coordinates = $object->coordinates[0]; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | try { |
||
| 28 | 6 | return GeoJson::jsonUnserialize($object); |
|
| 29 | } catch (GeoJsonException|\InvalidArgumentException $e) { |
||
| 30 | throw new ParseException('Failed to parse geometry', 0, $e); |
||
| 31 | } |
||
| 34 |