| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 45 | public static function formatDistance(int $distance, int $precision = 1): string |
||
| 46 | { |
||
| 47 | if ($distance < 1000) { |
||
| 48 | return $distance.' m'; |
||
| 49 | } |
||
| 50 | |||
| 51 | --$precision; |
||
| 52 | |||
| 53 | $tmp = (int) floor($distance / 1000); |
||
| 54 | if (0 === $precision || 0 === $distance - ($tmp * 1000)) { |
||
| 55 | return round($distance / 1000, 1).' km'; |
||
| 56 | } |
||
| 57 | |||
| 58 | return $tmp.' km '.self::formatDistance($distance - ($tmp * 1000), $precision); |
||
| 59 | } |
||
| 61 |