Fix exception with AmountFormatter if Si prefix were enabled and no unit symbol were set.

Also this case is now prevented by Validator (as it is not very useful). Fixes issue #171.
This commit is contained in:
Jan Böhmer 2022-09-17 17:58:01 +02:00
parent 430c9fed67
commit 8338c0f2d6
4 changed files with 94 additions and 86 deletions

View file

@ -131,7 +131,8 @@ class AmountFormatter
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
return $unit->getUnit();
//When no unit is set, return empty string so that this can be formatted properly
return $unit->getUnit() ?? '';
}
return '';