| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 11 | public function parseCoordinates($coordinateString) : array |
|
| 20 | { |
||
| 21 | 11 | $values = explode(",", $coordinateString); |
|
| 22 | |||
| 23 | 11 | if (count($values) != 2) { |
|
| 24 | 4 | throw new BadFormatException("Värdet var fel formaterat!"); |
|
| 25 | } |
||
| 26 | |||
| 27 | 7 | $lat = $values[0]; |
|
| 28 | 7 | $long = $values[1]; |
|
| 29 | |||
| 30 | 7 | if (!floatval($lat)) { |
|
| 31 | 1 | throw new BadFormatException("Latituden <b>$lat</b> har fel format."); |
|
| 32 | } |
||
| 33 | 6 | if (!floatval($long)) { |
|
| 34 | 1 | throw new BadFormatException("Longituden <b>$long</b> har fel format."); |
|
| 35 | } |
||
| 36 | |||
| 37 | 5 | $coordinates = ["lat" => $lat, "long" => $long]; |
|
| 38 | 5 | return $coordinates; |
|
| 39 | } |
||
| 54 |