phpvms/app/Support/Units/Distance.php
Nabeel S e6d38f9338
Add PHP 7.4 support (#464)
* Add PHP 7.4 to build matrix

* DB fix

* YAML parser fix in test data

* Show versions

* Package updates

* Track used ICAOs

* 7.4 METAR parsing fix

* METAR parser fix

* Formatting

* Add meters to response units

* Call instance for unit conversion

* Return value

* Catch exception for unknown quantity

* Comment fix

* Formatting

* METAR parsing fixes on PHP 7.4

* Package updates

* More random airport ID

* More random airport ID

* Properly disable toolbar

* Semver written out to version file

* Use dev as default identifier
2019-12-11 12:57:18 -05:00

36 lines
703 B
PHP

<?php
namespace App\Support\Units;
use App\Contracts\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Length;
class Distance extends Unit
{
public $responseUnits = [
'm',
'km',
'mi',
'nmi',
];
/**
* Distance constructor.
*
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/
public function __construct($value, string $unit)
{
if (empty($value)) {
$value = 0;
}
$this->unit = setting('units.distance');
$this->instance = new Length($value, $unit);
}
}