public static function AreaUnit::assertExists in Physical Fields 8
Asserts that the given unit exists.
Parameters
string $unit: The unit.
Throws
\InvalidArgumentException
Overrides UnitInterface::assertExists
1 call to AreaUnit::assertExists()
- AreaUnit::getBaseFactor in src/
AreaUnit.php - Gets the base factor for the given unit.
File
- src/
AreaUnit.php, line 58
Class
- AreaUnit
- Provides area units.
Namespace
Drupal\physicalCode
public static function assertExists($unit) {
$allowed_units = [
self::SQUARE_MILLIMETER,
self::SQUARE_CENTIMETER,
self::SQUARE_METER,
self::SQUARE_INCH,
self::SQUARE_FOOT,
self::HECTARE,
];
if (!in_array($unit, $allowed_units)) {
throw new \InvalidArgumentException(sprintf('Invalid area unit "%s" provided.', $unit));
}
}