12848091a2
Update to Laravel 9 and PHP 8+ Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
40 lines
888 B
PHP
40 lines
888 B
PHP
<?php
|
|
|
|
namespace App\Support\Units;
|
|
|
|
use App\Contracts\Unit;
|
|
use PhpUnitsOfMeasure\PhysicalQuantity\Length;
|
|
|
|
class Altitude extends Unit
|
|
{
|
|
public array $responseUnits = [
|
|
'ft',
|
|
'km',
|
|
'm',
|
|
];
|
|
|
|
/**
|
|
* @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->localUnit = setting('units.altitude');
|
|
$this->internalUnit = config('phpvms.internal_units.altitude');
|
|
|
|
if ($value instanceof self) {
|
|
$value->toUnit($unit);
|
|
$this->instance = $value->instance;
|
|
} else {
|
|
$this->instance = new Length($value, $unit);
|
|
}
|
|
}
|
|
}
|