toUnit($unit); return (string) round($value, 2); } /** * Return value in native unit as integer * @return array */ public function toNumber() { return $this->toArray(); } /** * For the HTTP Resource call */ public function toObject(): array { return [ 'mi' => round($this->toUnit('miles'), 2), 'nmi' => round($this->toUnit('nmi'), 2), 'km' => round($this->toUnit('meters') / 1000, 2), ]; } /** * Get the instance as an array. */ public function toArray() { return round($this->toUnit( config('phpvms.internal_units.distance') ), 2); } }