diff --git a/src/MDConcWeights.php b/src/MDConcWeights.php index a626133..3a4654a 100644 --- a/src/MDConcWeights.php +++ b/src/MDConcWeights.php @@ -10,14 +10,15 @@ declare(strict_types = 1); * Provides lists for categorizing misspelled sizes. */ final class MDConcWeights implements MDImporterConcordanceListInterface { + /** - * Require a function for getting the concordance target. + * Matches. * * @param string $input Input string. * * @return MDWeightUnit|false */ - public static function getConcordanceTarget(string $input):MDWeightUnit|false { + private static function _match(string $input):MDWeightUnit|false { return match($input) { @@ -34,4 +35,27 @@ final class MDConcWeights implements MDImporterConcordanceListInterface { }; } + + /** + * Require a function for getting the concordance target. + * + * @param string $input Input string. + * + * @return MDWeightUnit|false + */ + public static function getConcordanceTarget(string $input):MDWeightUnit|false { + + try { + return self::_match($input); + } + catch (MDInvalidWeightUnit $e) { + + if (is_numeric($input) || is_numeric(strtr($input, ['.' => '', ',' => '']))) { + return false; + } + + return self::_match(trim($input)); + } + + } }