You are here

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

Class

AreaUnit
Provides area units.

Namespace

Drupal\physical

Code

public static function getBaseFactor($unit) {
  self::assertExists($unit);
  $factors = [
    self::SQUARE_MILLIMETER => '0.000001',
    self::SQUARE_CENTIMETER => '0.0001',
    self::SQUARE_METER => '1',
    self::SQUARE_INCH => '0.0006451600',
    self::SQUARE_FOOT => '0.09290304',
    self::HECTARE => '10000',
  ];
  return $factors[$unit];
}