public static function VolumeUnit::getBaseFactor in Physical Fields 8
Gets the base factor for the given unit.
Used for converting measurements to and from the base unit. Use multiplication to convert a measurement to the base unit, and division to convert from the base unit (into the given unit).
Parameters
string $unit: The unit.
Return value
string The base factor.
Overrides UnitInterface::getBaseFactor
File
- src/
VolumeUnit.php, line 51
Class
- VolumeUnit
- Provides volume units.
Namespace
Drupal\physicalCode
public static function getBaseFactor($unit) {
self::assertExists($unit);
$factors = [
self::MILLILITER => '0.000001',
self::CENTILITER => '0.00001',
self::DECILITER => '0.0001',
self::LITER => '0.001',
self::CUBIC_MILLIMETER => '0.000000001',
self::CUBIC_CENTIMETER => '0.000001',
self::CUBIC_METER => '1',
self::CUBIC_INCH => '0.00001638706',
self::CUBIC_FOOT => '0.02831685',
self::FLUID_OUNCE => '0.00002957353',
self::US_GALLON => '0.0037854118',
];
return $factors[$unit];
}