Move internal unit definitions to config file #189
This commit is contained in:
@@ -9,11 +9,6 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
*/
|
||||
class Altitude extends \PhpUnitsOfMeasure\PhysicalQuantity\Length implements Arrayable
|
||||
{
|
||||
/**
|
||||
* The unit that this is stored as
|
||||
*/
|
||||
public const STORAGE_UNIT = 'feet';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -40,6 +35,8 @@ class Altitude extends \PhpUnitsOfMeasure\PhysicalQuantity\Length implements Arr
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return round($this->toUnit(self::STORAGE_UNIT), 2);
|
||||
return round($this->toUnit(
|
||||
config('phpvms.internal_units.altitude')
|
||||
), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,6 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
*/
|
||||
class Distance extends \PhpUnitsOfMeasure\PhysicalQuantity\Length implements Arrayable
|
||||
{
|
||||
/**
|
||||
* The unit that this is stored as
|
||||
*/
|
||||
public const STORAGE_UNIT = 'nmi';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -41,6 +36,8 @@ class Distance extends \PhpUnitsOfMeasure\PhysicalQuantity\Length implements Arr
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return round($this->toUnit(self::STORAGE_UNIT), 2);
|
||||
return round($this->toUnit(
|
||||
config('phpvms.internal_units.distance')
|
||||
), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ class Mass extends \PhpUnitsOfMeasure\PhysicalQuantity\Mass implements Arrayable
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return round($this->toUnit(self::STORAGE_UNIT), 2);
|
||||
return round($this->toUnit(
|
||||
config('phpvms.internal_units.mass')
|
||||
), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,6 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
*/
|
||||
class Velocity extends \PhpUnitsOfMeasure\PhysicalQuantity\Velocity implements Arrayable
|
||||
{
|
||||
/**
|
||||
* The unit that this is stored as
|
||||
*/
|
||||
public const STORAGE_UNIT = 'knot';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -30,7 +25,7 @@ class Velocity extends \PhpUnitsOfMeasure\PhysicalQuantity\Velocity implements A
|
||||
public function toObject()
|
||||
{
|
||||
return [
|
||||
'knot' => round($this->toUnit('knot'), 2),
|
||||
'knots' => round($this->toUnit('knots'), 2),
|
||||
'km/h' => round($this->toUnit('km/h'), 2),
|
||||
];
|
||||
}
|
||||
@@ -40,6 +35,8 @@ class Velocity extends \PhpUnitsOfMeasure\PhysicalQuantity\Velocity implements A
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return round($this->toUnit(self::STORAGE_UNIT), 2);
|
||||
return round($this->toUnit(
|
||||
config('phpvms.internal_units.velocity')
|
||||
), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,6 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
*/
|
||||
class Volume extends \PhpUnitsOfMeasure\PhysicalQuantity\Volume implements Arrayable
|
||||
{
|
||||
/**
|
||||
* The unit that this is stored as
|
||||
*/
|
||||
public const STORAGE_UNIT = 'gal';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -40,6 +35,8 @@ class Volume extends \PhpUnitsOfMeasure\PhysicalQuantity\Volume implements Array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return round($this->toUnit(self::STORAGE_UNIT), 2);
|
||||
return round($this->toUnit(
|
||||
config('phpvms.internal_units.volume')
|
||||
), 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user