phpvms/app/Support/Units/Velocity.php

35 lines
691 B
PHP
Raw Normal View History

2018-02-11 11:16:32 +08:00
<?php
namespace App\Support\Units;
2018-02-21 12:33:09 +08:00
use App\Contracts\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Velocity as VelocityUnit;
2018-02-11 11:16:32 +08:00
/**
* Class Velocity
*/
class Velocity extends Unit
2018-02-11 11:16:32 +08:00
{
public $responseUnits = [
'km/h',
'knots',
];
2018-02-11 11:16:32 +08:00
/**
* @param float $value
* @param string $unit
2018-08-27 00:40:04 +08:00
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
2018-02-11 11:16:32 +08:00
*/
public function __construct($value, string $unit)
2018-02-11 11:16:32 +08:00
{
if (empty($value)) {
$value = 0;
}
$this->unit = setting('units.speed');
$this->instance = new VelocityUnit($value, $unit);
2018-02-11 11:16:32 +08:00
}
}