2018-02-21 04:07:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Support\Units;
|
2018-02-21 12:33:09 +08:00
|
|
|
|
2018-04-08 09:52:12 +08:00
|
|
|
use App\Interfaces\Unit;
|
|
|
|
use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
|
2018-02-21 04:07:33 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @package App\Support\Units
|
|
|
|
*/
|
2018-04-08 09:52:12 +08:00
|
|
|
class Fuel extends Unit
|
2018-02-21 04:07:33 +08:00
|
|
|
{
|
|
|
|
/**
|
2018-04-08 09:52:12 +08:00
|
|
|
* @param float $value
|
|
|
|
* @param string $unit
|
|
|
|
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
|
|
|
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
2018-02-21 04:07:33 +08:00
|
|
|
*/
|
2018-04-08 09:52:12 +08:00
|
|
|
public function __construct(float $value, string $unit)
|
2018-02-21 04:07:33 +08:00
|
|
|
{
|
2018-04-08 09:52:12 +08:00
|
|
|
$this->unit = setting('units.fuel');
|
|
|
|
$this->instance = new Mass($value, $unit);
|
2018-03-20 09:50:40 +08:00
|
|
|
|
2018-04-08 09:52:12 +08:00
|
|
|
$this->units = [
|
|
|
|
'kg' => round($this->instance->toUnit('kg'), 2),
|
|
|
|
'lbs' => round($this->instance->toUnit('lbs'), 2),
|
2018-02-21 04:07:33 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|