Fix for bad unit conversions in API responses
This commit is contained in:
@@ -20,8 +20,12 @@ class Altitude extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.altitude');
|
||||
$this->instance = new Length($value, $unit);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,12 @@ class Distance extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.distance');
|
||||
$this->instance = new Length($value, $unit);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,12 @@ class Fuel extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.fuel');
|
||||
$this->instance = new Mass($value, $unit);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,12 @@ class Mass extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.weight');
|
||||
$this->instance = new MassUnit($value, $unit);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,12 @@ class Pressure extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.temperature');
|
||||
$this->instance = new PressureUnit($value, $unit);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,12 @@ class Temperature extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.temperature');
|
||||
$this->instance = new TemperatureUnit($value, $unit);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,12 @@ class Velocity extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.speed');
|
||||
$this->instance = new VelocityUnit($value, $unit);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,12 @@ class Volume extends Unit
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
public function __construct(float $value, string $unit)
|
||||
public function __construct($value, string $unit)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$this->unit = setting('units.volume');
|
||||
$this->instance = new VolumeUnit($value, $unit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user