You are here

public static function TemperatureUnit::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/TemperatureUnit.php, line 35

Class

TemperatureUnit
Provides common temperature units.

Namespace

Drupal\physical

Code

public static function getBaseFactor($unit) {
  self::assertExists($unit);

  // Not used, see Temperature::convert().
  $factors = [
    self::KELVIN => '274.15',
    self::CELSIUS => '1',
    self::FAHRENHEIT => '33.8',
  ];
  return $factors[$unit];
}