phpvms/app/Support/Units/Mass.php
2019-09-20 09:05:09 -04:00

32 lines
646 B
PHP

<?php
namespace App\Support\Units;
use App\Contracts\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Mass as MassUnit;
class Mass extends Unit
{
public $responseUnits = [
'kg',
'lbs',
];
/**
* @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.weight');
$this->instance = new MassUnit($value, $unit);
}
}