Update concordance lists for new measurements implementation

This commit is contained in:
2024-11-26 11:46:29 +01:00
parent 866ef3c714
commit 4beff90c42
4 changed files with 108 additions and 114 deletions

View File

@@ -10,27 +10,25 @@ declare(strict_types = 1);
* Provides lists for categorizing misspelled sizes.
*/
final class MDConcWeights implements MDImporterConcordanceListInterface {
private const WEIGHTS_LIST = [
"cm" => "", // Default
"Gramm" => "g",
"г" => "g",
];
/**
* Require a function for getting the concordance target.
*
* @param string $input Input string.
*
* @return string
* @return MDWeightUnit|false
*/
public static function getConcordanceTarget(string $input):string {
public static function getConcordanceTarget(string $input):MDWeightUnit|false {
if (!isset(self::WEIGHTS_LIST[$input])) {
throw new MDImporterMissingConcordance("Unknown weight type: " . $input);
}
return match($input) {
return self::WEIGHTS_LIST[$input];
"cm" => false,
"Gramm",
"г" => MDWeightUnit::g,
default => throw new MDInvalidWeightUnit("Invalid weight unit " . $input),
};
}
}