public static function MeasurementType::assertExists in Physical Fields 8
Asserts that the given measurement type exists.
Parameters
string $type: The measurement type.
Throws
\InvalidArgumentException
2 calls to MeasurementType::assertExists()
- MeasurementType::getClass in src/
MeasurementType.php - Gets the class for the given measurement type.
- MeasurementType::getUnitClass in src/
MeasurementType.php - Gets the unit class for the given measurement type.
File
- src/
MeasurementType.php, line 84
Class
- MeasurementType
- Provides measurement types.
Namespace
Drupal\physicalCode
public static function assertExists($type) {
$allowed_types = [
self::AREA,
self::LENGTH,
self::TEMPERATURE,
self::VOLUME,
self::WEIGHT,
];
if (!in_array($type, $allowed_types)) {
throw new \InvalidArgumentException(sprintf('Invalid measurement type "%s" provided.', $type));
}
}