diff --git a/src/NodaUncertaintyHelper.php b/src/NodaUncertaintyHelper.php index 23a6b58..c9f2a19 100644 --- a/src/NodaUncertaintyHelper.php +++ b/src/NodaUncertaintyHelper.php @@ -232,8 +232,7 @@ final class NodaUncertaintyHelper { */ public static function trim(string $input):string { - $input = \trim($input, ", \t\n\r\n;-:"); - return $input; + return \trim($input, ", \t\n\r\n;-:"); } @@ -280,7 +279,7 @@ final class NodaUncertaintyHelper { */ public static function guessTimeCertainty(string $zeit_name):bool { - $zeit_name = \strtolower($zeit_name); + $zeit_name = self::trim(strtolower($zeit_name)); // Attempt to guess uncertainty based on prefixes. foreach (self::TIME_UNCERTAINTY_PREFIXES as $prefix) { @@ -343,7 +342,7 @@ final class NodaUncertaintyHelper { */ public static function guessPlaceCertainty(string $ort_name):bool { - $ort_name = \trim(\strtolower($ort_name), ', ;-_'); + $ort_name = self::trim(\strtolower($ort_name)); // Attempt to guess uncertainty based on prefixes. foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { @@ -404,7 +403,7 @@ final class NodaUncertaintyHelper { */ public static function guessPersinstCertainty(string $name):bool { - $name = \trim(\strtolower($name), ', ;-_'); + $name = self::trim(\strtolower($name)); // Attempt to guess uncertainty based on prefixes. foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_PREFIXES as $prefix) { diff --git a/tests/NodaUncertaintyHelperTest.php b/tests/NodaUncertaintyHelperTest.php index 14c0594..b8fc387 100644 --- a/tests/NodaUncertaintyHelperTest.php +++ b/tests/NodaUncertaintyHelperTest.php @@ -26,6 +26,9 @@ final class NodaUncertaintyHelperTest extends TestCase { public function testCleanUncertaintyIndicatorsTime():void { self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("wohl 1950")); + self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950?")); + self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950?,")); + self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950,")); self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950")); }