interface UnitInterface in Physical Fields 8
Provides the interface for unit classes.
A unit class defines all possible units for a measurement type.
Hierarchy
- interface \Drupal\physical\UnitInterface
Expanded class hierarchy of UnitInterface
All classes that implement UnitInterface
File
- src/
UnitInterface.php, line 10
Namespace
Drupal\physicalView source
interface UnitInterface {
/**
* Gets the labels for the defined units.
*
* @return array
* An array of labels keyed by unit.
*/
public static function getLabels();
/**
* Gets the base unit.
*
* @return string
* The base unit.
*/
public static function getBaseUnit();
/**
* 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).
*
* @param string $unit
* The unit.
*
* @return string
* The base factor.
*/
public static function getBaseFactor($unit);
/**
* Asserts that the given unit exists.
*
* @param string $unit
* The unit.
*
* @throws \InvalidArgumentException
*/
public static function assertExists($unit);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UnitInterface:: |
public static | function | Asserts that the given unit exists. | 5 |
UnitInterface:: |
public static | function | Gets the base factor for the given unit. | 5 |
UnitInterface:: |
public static | function | Gets the base unit. | 5 |
UnitInterface:: |
public static | function | Gets the labels for the defined units. | 5 |