phpvms/app/Support/Units/Pressure.php
Nabeel S 12848091a2
Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
2022-03-14 11:45:18 -04:00

42 lines
948 B
PHP

<?php
namespace App\Support\Units;
use App\Contracts\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Pressure as PressureUnit;
/**
* Composition for the converter
*/
class Pressure extends Unit
{
public array $responseUnits = [
'atm',
'hPa',
];
/**
* @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.temperature');
$this->internalUnit = config('phpvms.internal_units.temperature');
if ($value instanceof self) {
$value->toUnit($unit);
$this->instance = $value->instance;
} else {
$this->instance = new PressureUnit($value, $unit);
}
}
}