Ran phpcbf over code
This commit is contained in:
		| @@ -10,7 +10,6 @@ declare(strict_types = 1); | ||||
|  * Abstract class to be inherited by classes for writing consolidated vocabulary names. | ||||
|  */ | ||||
| abstract class NodaConsolidatedNamesAbstract { | ||||
|  | ||||
|     /** | ||||
|      * This function sanitizes a string. | ||||
|      * | ||||
|   | ||||
| @@ -120,5 +120,4 @@ final class NodaConsolidatedNamesForPersinst extends NodaConsolidatedNamesAbstra | ||||
|         return \trim($name, " ;.\t" . PHP_EOL); | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -105,8 +105,7 @@ final class NodaConsolidatedNamesForPlaces extends NodaConsolidatedNamesAbstract | ||||
|  | ||||
|             // Skip entries like "Vaci utca 12 Budapest, Vaci utca" | ||||
|             $indicatorTrimmed = trim($indicator); | ||||
|             if ( | ||||
|                 (str_ends_with($parts[0], $indicatorTrimmed) && str_contains($parts[1], $indicatorTrimmed)) | ||||
|             if ((str_ends_with($parts[0], $indicatorTrimmed) && str_contains($parts[1], $indicatorTrimmed)) | ||||
|                 || (str_ends_with($parts[1], $indicatorTrimmed) && str_contains($parts[0], $indicatorTrimmed)) | ||||
|             ) { | ||||
|                 return $name; | ||||
| @@ -133,10 +132,8 @@ final class NodaConsolidatedNamesForPlaces extends NodaConsolidatedNamesAbstract | ||||
|  | ||||
|             } | ||||
|  | ||||
|  | ||||
|         } | ||||
|  | ||||
|  | ||||
|         return $name; | ||||
|  | ||||
|     } | ||||
| @@ -334,7 +331,6 @@ final class NodaConsolidatedNamesForPlaces extends NodaConsolidatedNamesAbstract | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Cleans and consolidates name parts appearing regularly in Ukrainian place names. | ||||
|      * | ||||
| @@ -427,15 +423,12 @@ final class NodaConsolidatedNamesForPlaces extends NodaConsolidatedNamesAbstract | ||||
|  | ||||
|             // If one of the parts is a blacklisted term or a cardinal directions, skip this | ||||
|  | ||||
|             if ( | ||||
|                 (in_array($parts[0], self::_COUNTRY_REWRITE_BLACKLISTED_TERMS, true) | ||||
|                     || in_array($parts[0], $cardinal_directions, true) | ||||
|                     || in_array(strtolower($parts[0]), $cardinal_directions, true) | ||||
|                 ) | ||||
|             if ((in_array($parts[0], self::_COUNTRY_REWRITE_BLACKLISTED_TERMS, true) | ||||
|                 || in_array($parts[0], $cardinal_directions, true) | ||||
|                 || in_array(strtolower($parts[0]), $cardinal_directions, true)) | ||||
|                 || (in_array($parts[1], self::_COUNTRY_REWRITE_BLACKLISTED_TERMS, true) | ||||
|                     || in_array($parts[1], $cardinal_directions, true) | ||||
|                     || in_array(strtolower($parts[1]), $cardinal_directions, true) | ||||
|                 ) | ||||
|                 || in_array($parts[1], $cardinal_directions, true) | ||||
|                 || in_array(strtolower($parts[1]), $cardinal_directions, true)) | ||||
|             ) { | ||||
|                 return $name; | ||||
|             } | ||||
|   | ||||
| @@ -10,7 +10,6 @@ declare(strict_types = 1); | ||||
|  * contains a string. | ||||
|  */ | ||||
| final class NodaDistinctlyTypedStrings { | ||||
|  | ||||
|     /** | ||||
|      * Checks the vocabulary database whether it contains a given string. | ||||
|      * | ||||
| @@ -40,5 +39,4 @@ final class NodaDistinctlyTypedStrings { | ||||
|         return $cur[0]; | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -11,7 +11,7 @@ declare(strict_types = 1); | ||||
|  */ | ||||
| final class NodaSplitTime { | ||||
|  | ||||
|     const DEFAULT_DATE = '0001-01-01'; | ||||
|     public const DEFAULT_DATE = '0001-01-01'; | ||||
|  | ||||
|     public readonly string $start_year; | ||||
|     public readonly string $end_year; | ||||
| @@ -40,11 +40,13 @@ final class NodaSplitTime { | ||||
|         $start_date = $end_date = $year . '-' . $month . '-' . $day; | ||||
|  | ||||
|         if ($before_after_indicator === NodaTimeBeforeAfterIndicator::before | ||||
|             || $before_after_indicator === NodaTimeBeforeAfterIndicator::until) { | ||||
|             || $before_after_indicator === NodaTimeBeforeAfterIndicator::until | ||||
|         ) { | ||||
|             $start_year = $start_date = '?'; | ||||
|         } | ||||
|         if ($before_after_indicator === NodaTimeBeforeAfterIndicator::after | ||||
|             || $before_after_indicator === NodaTimeBeforeAfterIndicator::since) { | ||||
|             || $before_after_indicator === NodaTimeBeforeAfterIndicator::since | ||||
|         ) { | ||||
|             $end_year = $end_date = '?'; | ||||
|         } | ||||
|  | ||||
| @@ -94,7 +96,6 @@ final class NodaSplitTime { | ||||
|             throw new MDgenericInvalidInputsException("Times with no certain end need to have a question mark (?) entered as a end date"); | ||||
|         } | ||||
|  | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -272,7 +273,6 @@ final class NodaSplitTime { | ||||
|  | ||||
|         return ""; | ||||
|  | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -330,7 +330,6 @@ final class NodaSplitTime { | ||||
|             $this->end_date = '9999-12-31'; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         if (!isset($this->start_date) && false !== $start_date) { | ||||
|             $this->start_date = date("Y-m-d", MD_STD::strtotime($start_date)); | ||||
|         } | ||||
| @@ -361,7 +360,5 @@ final class NodaSplitTime { | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -888,11 +888,10 @@ final class NodaTimeSplitter { | ||||
|  | ||||
|         $datum = self::clean_input($datum); | ||||
|  | ||||
|  | ||||
|         // TODO: Check if this is duplicate | ||||
|  | ||||
|         // 17. Jahrhundert | ||||
|         if (\preg_match("/^[0-9]{2}(\.|)" . self::REGEX_CENTURIES ."$/", $datum)) { | ||||
|         if (\preg_match("/^[0-9]{2}(\.|)" . self::REGEX_CENTURIES . "$/", $datum)) { | ||||
|             if ($centuryNo = \intval(\substr($datum, 0, 2))) { | ||||
|                 $centuryNo--; | ||||
|                 return new NodaSplitTime((string)$centuryNo . "01", \strval($centuryNo + 1) . "00"); | ||||
|   | ||||
| @@ -94,9 +94,9 @@ final class NodaUncertaintyHelper { | ||||
|         "Без датування", // No dating | ||||
|         "б.р.", // No dating | ||||
|         "б.д.", // No dating | ||||
|     ]; | ||||
|         ]; | ||||
|  | ||||
|     const TIME_UNCERTAINTY_PREFIXES = [ | ||||
|         const TIME_UNCERTAINTY_PREFIXES = [ | ||||
|         "c. ", | ||||
|         "ca ", | ||||
|         "ca. ", | ||||
| @@ -130,9 +130,9 @@ final class NodaUncertaintyHelper { | ||||
|         "майже",      // UK: Almost / nearly / about | ||||
|         "орієнтовно", // UK: approximately | ||||
|         "Прибл.",     // UK: approximately | ||||
|     ]; | ||||
|         ]; | ||||
|  | ||||
|     const TIME_UNCERTAINTY_SUFFIXES = [ | ||||
|         const TIME_UNCERTAINTY_SUFFIXES = [ | ||||
|         "(?)", | ||||
|         "?", | ||||
|         " (ca.)", | ||||
| @@ -145,11 +145,11 @@ final class NodaUncertaintyHelper { | ||||
|         ", um", | ||||
|         " (um)", | ||||
|         " (ок.)", | ||||
|     ]; | ||||
|         ]; | ||||
|  | ||||
|     /** | ||||
|      * Substrings used to express uncertainty about the validity of a place name. | ||||
|      */ | ||||
|         /** | ||||
|          * Substrings used to express uncertainty about the validity of a place name. | ||||
|          */ | ||||
|         const PLACE_INDICATORS_DISALLOWED = [ | ||||
|         "Unbekannt", | ||||
|         "unbekannt", | ||||
| @@ -173,9 +173,9 @@ final class NodaUncertaintyHelper { | ||||
|         "не вказано", // No place | ||||
|         "не вказане", // No place | ||||
|         "невідоме", // No place | ||||
|     ]; | ||||
|         ]; | ||||
|  | ||||
|     const PLACE_UNCERTAINTY_PREFIXES = [ | ||||
|         const PLACE_UNCERTAINTY_PREFIXES = [ | ||||
|         "ca ", | ||||
|         "Ca ", | ||||
|         "ca. ", | ||||
| @@ -210,9 +210,9 @@ final class NodaUncertaintyHelper { | ||||
|         "Wahrscheinlich ", | ||||
|         "можливо", | ||||
|         "?", | ||||
|     ]; | ||||
|         ]; | ||||
|  | ||||
|     const PLACE_UNCERTAINTY_SUFFIXES = [ | ||||
|         const PLACE_UNCERTAINTY_SUFFIXES = [ | ||||
|         "(?)", | ||||
|         "(vermutl.)", | ||||
|         "[vermutl.]", | ||||
| @@ -221,206 +221,206 @@ final class NodaUncertaintyHelper { | ||||
|         "(wohl)", | ||||
|         "[wohl]", | ||||
|         "?", | ||||
|     ]; | ||||
|         ]; | ||||
|  | ||||
|     /** | ||||
|      * Trims common characters and charater marks. | ||||
|      * | ||||
|      * @param string $input Input text. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public static function trim(string $input):string { | ||||
|         /** | ||||
|          * Trims common characters and charater marks. | ||||
|          * | ||||
|          * @param string $input Input text. | ||||
|          * | ||||
|          * @return string | ||||
|          */ | ||||
|         public static function trim(string $input):string { | ||||
|  | ||||
|         $input = \trim($input, ", \t\n\r\n;-:"); | ||||
|         return $input; | ||||
|             $input = \trim($input, ", \t\n\r\n;-:"); | ||||
|             return $input; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Removes uncertainty indicators from an time name. | ||||
|      * | ||||
|      * @param string $name Input string. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public static function cleanUncertaintyIndicatorsTime(string $name):string { | ||||
|  | ||||
|         $name = self::trim($name); | ||||
|  | ||||
|         if (\in_array($name, self::TIME_INDICATORS_DISALLOWED, true)) { | ||||
|             return ""; | ||||
|         } | ||||
|  | ||||
|         // Remove uncertainty prefixes | ||||
|         foreach (NodaUncertaintyHelper::TIME_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|             if (\substr($name, 0, \strlen($prefix)) === "$prefix") { | ||||
|                 $name = substr($name, \strlen($prefix)); | ||||
|         /** | ||||
|          * Removes uncertainty indicators from an time name. | ||||
|          * | ||||
|          * @param string $name Input string. | ||||
|          * | ||||
|          * @return string | ||||
|          */ | ||||
|         public static function cleanUncertaintyIndicatorsTime(string $name):string { | ||||
|  | ||||
|             $name = self::trim($name); | ||||
|  | ||||
|             if (\in_array($name, self::TIME_INDICATORS_DISALLOWED, true)) { | ||||
|                 return ""; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Remove uncertainty sufixes | ||||
|         foreach (NodaUncertaintyHelper::TIME_UNCERTAINTY_SUFFIXES as $suffix) { | ||||
|             if (\substr($name, \strlen($suffix) * -1) === "$suffix") { | ||||
|                 $name = \substr($name, 0, \strlen($suffix) * -1); | ||||
|             // Remove uncertainty prefixes | ||||
|             foreach (NodaUncertaintyHelper::TIME_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|                 if (\substr($name, 0, \strlen($prefix)) === "$prefix") { | ||||
|                     $name = substr($name, \strlen($prefix)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return self::trim($name); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Attempts guessing whether time is uncertain. Returns true if the name | ||||
|      * indicates certainty, false if it indicates uncertainty. | ||||
|      * | ||||
|      * @param string $zeit_name Time name. | ||||
|      * | ||||
|      * @return boolean | ||||
|      */ | ||||
|     public static function guessTimeCertainty(string $zeit_name):bool { | ||||
|  | ||||
|         $zeit_name = \strtolower($zeit_name); | ||||
|  | ||||
|         // Attempt to guess uncertainty based on prefixes. | ||||
|         foreach (self::TIME_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|             if (\substr($zeit_name, 0, \strlen($prefix)) === $prefix) { | ||||
|                 return false; // Uncertainty found | ||||
|             // Remove uncertainty sufixes | ||||
|             foreach (NodaUncertaintyHelper::TIME_UNCERTAINTY_SUFFIXES as $suffix) { | ||||
|                 if (\substr($name, \strlen($suffix) * -1) === "$suffix") { | ||||
|                     $name = \substr($name, 0, \strlen($suffix) * -1); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return self::trim($name); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         // Attempt to guess uncertainty based on prefixes. | ||||
|         foreach (self::TIME_UNCERTAINTY_SUFFIXES as $prefix) { | ||||
|             if (\substr($zeit_name, -1 * \strlen($prefix)) === $prefix) { | ||||
|                 return false; // Uncertainty found | ||||
|         /** | ||||
|          * Attempts guessing whether time is uncertain. Returns true if the name | ||||
|          * indicates certainty, false if it indicates uncertainty. | ||||
|          * | ||||
|          * @param string $zeit_name Time name. | ||||
|          * | ||||
|          * @return boolean | ||||
|          */ | ||||
|         public static function guessTimeCertainty(string $zeit_name):bool { | ||||
|  | ||||
|             $zeit_name = \strtolower($zeit_name); | ||||
|  | ||||
|             // Attempt to guess uncertainty based on prefixes. | ||||
|             foreach (self::TIME_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|                 if (\substr($zeit_name, 0, \strlen($prefix)) === $prefix) { | ||||
|                     return false; // Uncertainty found | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return true; // No uncertainty found | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Removes uncertainty indicators from an place name. | ||||
|      * | ||||
|      * @param string $ort_name Input string. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public static function cleanUncertaintyIndicatorsPlace(string $ort_name):string { | ||||
|  | ||||
|         $ort_name = self::trim($ort_name); | ||||
|  | ||||
|         if (\in_array($ort_name, self::PLACE_INDICATORS_DISALLOWED, true)) { | ||||
|             return ""; | ||||
|         } | ||||
|  | ||||
|         // Remove uncertainty prefixes | ||||
|         foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|             if (\substr($ort_name, 0, \strlen($prefix)) === "$prefix") { | ||||
|                 $ort_name = substr($ort_name, \strlen($prefix)); | ||||
|             // Attempt to guess uncertainty based on prefixes. | ||||
|             foreach (self::TIME_UNCERTAINTY_SUFFIXES as $prefix) { | ||||
|                 if (\substr($zeit_name, -1 * \strlen($prefix)) === $prefix) { | ||||
|                     return false; // Uncertainty found | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return true; // No uncertainty found | ||||
|  | ||||
|         } | ||||
|  | ||||
|         // Remove uncertainty sufixes | ||||
|         foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_SUFFIXES as $suffix) { | ||||
|             if (\substr($ort_name, \strlen($suffix) * -1) === "$suffix") { | ||||
|                 $ort_name = \substr($ort_name, 0, \strlen($suffix) * -1); | ||||
|         /** | ||||
|          * Removes uncertainty indicators from an place name. | ||||
|          * | ||||
|          * @param string $ort_name Input string. | ||||
|          * | ||||
|          * @return string | ||||
|          */ | ||||
|         public static function cleanUncertaintyIndicatorsPlace(string $ort_name):string { | ||||
|  | ||||
|             $ort_name = self::trim($ort_name); | ||||
|  | ||||
|             if (\in_array($ort_name, self::PLACE_INDICATORS_DISALLOWED, true)) { | ||||
|                 return ""; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return self::trim($ort_name); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Attempts guessing whether place is uncertain. Returns true if the name | ||||
|      * indicates certainty, false if it indicates uncertainty. | ||||
|      * | ||||
|      * @param string $ort_name Place name. | ||||
|      * | ||||
|      * @return boolean | ||||
|      */ | ||||
|     public static function guessPlaceCertainty(string $ort_name):bool { | ||||
|  | ||||
|         $ort_name = \strtolower($ort_name); | ||||
|  | ||||
|         // Attempt to guess uncertainty based on prefixes. | ||||
|         foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|             if (\substr($ort_name, 0, \strlen($prefix)) === $prefix) { | ||||
|                 return false; // Uncertain | ||||
|             // Remove uncertainty prefixes | ||||
|             foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|                 if (\substr($ort_name, 0, \strlen($prefix)) === "$prefix") { | ||||
|                     $ort_name = substr($ort_name, \strlen($prefix)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Attempt to guess uncertainty based on prefixes. | ||||
|         foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_SUFFIXES as $prefix) { | ||||
|             if (\substr($ort_name, -1 * \strlen($prefix)) === $prefix) { | ||||
|                 return false; // Uncertain | ||||
|             // Remove uncertainty sufixes | ||||
|             foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_SUFFIXES as $suffix) { | ||||
|                 if (\substr($ort_name, \strlen($suffix) * -1) === "$suffix") { | ||||
|                     $ort_name = \substr($ort_name, 0, \strlen($suffix) * -1); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return self::trim($ort_name); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         return true; // Certain / no uncertainty found | ||||
|         /** | ||||
|          * Attempts guessing whether place is uncertain. Returns true if the name | ||||
|          * indicates certainty, false if it indicates uncertainty. | ||||
|          * | ||||
|          * @param string $ort_name Place name. | ||||
|          * | ||||
|          * @return boolean | ||||
|          */ | ||||
|         public static function guessPlaceCertainty(string $ort_name):bool { | ||||
|  | ||||
|     } | ||||
|             $ort_name = \strtolower($ort_name); | ||||
|  | ||||
|     /** | ||||
|      * Removes uncertainty indicators from an actor name. | ||||
|      * | ||||
|      * @param string $value Input string. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public static function cleanUncertaintyIndicatorsPersinst(string $value):string { | ||||
|  | ||||
|         $value = self::trim($value); | ||||
|  | ||||
|         if (\in_array(trim($value, ";. "), self::PERSINST_INDICATORS_DISALLOWED, true)) { | ||||
|             return ""; | ||||
|         } | ||||
|  | ||||
|         foreach (self::PERSINST_UNCERTAINTY_PREFIXES as $toRemove) { | ||||
|             if (\mb_substr($value, 0, \mb_strlen($toRemove)) === $toRemove) { | ||||
|                 $value = substr($value, \mb_strlen($toRemove)); | ||||
|             // Attempt to guess uncertainty based on prefixes. | ||||
|             foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|                 if (\substr($ort_name, 0, \strlen($prefix)) === $prefix) { | ||||
|                     return false; // Uncertain | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         foreach (self::PLACE_UNCERTAINTY_SUFFIXES as $suffix) { | ||||
|             if (\mb_substr($value, \mb_strlen($suffix) * -1) === "$suffix") { | ||||
|                 $value = \mb_substr($value, 0, \mb_strlen($suffix) * -1); | ||||
|             // Attempt to guess uncertainty based on prefixes. | ||||
|             foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_SUFFIXES as $prefix) { | ||||
|                 if (\substr($ort_name, -1 * \strlen($prefix)) === $prefix) { | ||||
|                     return false; // Uncertain | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return true; // Certain / no uncertainty found | ||||
|  | ||||
|         } | ||||
|  | ||||
|         return self::trim($value); | ||||
|         /** | ||||
|          * Removes uncertainty indicators from an actor name. | ||||
|          * | ||||
|          * @param string $value Input string. | ||||
|          * | ||||
|          * @return string | ||||
|          */ | ||||
|         public static function cleanUncertaintyIndicatorsPersinst(string $value):string { | ||||
|  | ||||
|     } | ||||
|             $value = self::trim($value); | ||||
|  | ||||
|     /** | ||||
|      * Attempts guessing whether persinst is uncertain. Returns true if the name | ||||
|      * indicates certainty, false if it indicates uncertainty. | ||||
|      * | ||||
|      * @param string $name Persinst name. | ||||
|      * | ||||
|      * @return boolean | ||||
|      */ | ||||
|     public static function guessPersinstCertainty(string $name):bool { | ||||
|  | ||||
|         $name = \trim(\strtolower($name)); | ||||
|  | ||||
|         // Attempt to guess uncertainty based on prefixes. | ||||
|         foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|             if (\substr($name, 0, \strlen($prefix)) === $prefix) { | ||||
|                 return false; // Uncertain | ||||
|             if (\in_array(trim($value, ";. "), self::PERSINST_INDICATORS_DISALLOWED, true)) { | ||||
|                 return ""; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Attempt to guess uncertainty based on prefixes. | ||||
|         foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_SUFFIXES as $prefix) { | ||||
|             if (\substr($name, -1 * \strlen($prefix)) === $prefix) { | ||||
|                 return false; // Uncertain | ||||
|             foreach (self::PERSINST_UNCERTAINTY_PREFIXES as $toRemove) { | ||||
|                 if (\mb_substr($value, 0, \mb_strlen($toRemove)) === $toRemove) { | ||||
|                     $value = substr($value, \mb_strlen($toRemove)); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             foreach (self::PLACE_UNCERTAINTY_SUFFIXES as $suffix) { | ||||
|                 if (\mb_substr($value, \mb_strlen($suffix) * -1) === "$suffix") { | ||||
|                     $value = \mb_substr($value, 0, \mb_strlen($suffix) * -1); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return self::trim($value); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         return true; // Certain / no uncertainty found | ||||
|         /** | ||||
|          * Attempts guessing whether persinst is uncertain. Returns true if the name | ||||
|          * indicates certainty, false if it indicates uncertainty. | ||||
|          * | ||||
|          * @param string $name Persinst name. | ||||
|          * | ||||
|          * @return boolean | ||||
|          */ | ||||
|         public static function guessPersinstCertainty(string $name):bool { | ||||
|  | ||||
|     } | ||||
|             $name = \trim(\strtolower($name)); | ||||
|  | ||||
|             // Attempt to guess uncertainty based on prefixes. | ||||
|             foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_PREFIXES as $prefix) { | ||||
|                 if (\substr($name, 0, \strlen($prefix)) === $prefix) { | ||||
|                     return false; // Uncertain | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             // Attempt to guess uncertainty based on prefixes. | ||||
|             foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_SUFFIXES as $prefix) { | ||||
|                 if (\substr($name, -1 * \strlen($prefix)) === $prefix) { | ||||
|                     return false; // Uncertain | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return true; // Certain / no uncertainty found | ||||
|  | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -19,9 +19,9 @@ final class NodaValidationHelper { | ||||
|      * made. | ||||
|      * | ||||
|      * @param string $description Input descrition. | ||||
|      * @param string $name       Names of the actor. Optional. Setting this enables | ||||
|      *                           checks e.g. to prevent duplicating the actor name | ||||
|      *                           as a description. | ||||
|      * @param string $name        Names of the actor. Optional. Setting this enables | ||||
|      *                            checks e.g. to prevent duplicating the actor name | ||||
|      *                            as a description. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|   | ||||
| @@ -56,7 +56,6 @@ final class NodaConsolidatedNamesForPlacesTest extends TestCase { | ||||
|         self::assertEquals("Deák Ferenc utca 16-18. (Budapest, 5. kerület)", NodaConsolidatedNamesForPlaces::consolidate_name("hu", "Deák Ferenc utca 16-18. Budapest, V.")); | ||||
|         self::assertEquals("Deák Ferenc utca 16-18. Budapest, V. abc", NodaConsolidatedNamesForPlaces::consolidate_name("hu", "Deák Ferenc utca 16-18. Budapest, V. abc")); | ||||
|  | ||||
|  | ||||
|         // Rewriting country names in brackets | ||||
|         self::assertEquals("Köln (Deutschland)", NodaConsolidatedNamesForPlaces::consolidate_name("de", "Deutschland-Köln")); | ||||
|         self::assertEquals("Köln (Deutschland)", NodaConsolidatedNamesForPlaces::consolidate_name("de", "Deutschland, Köln")); | ||||
|   | ||||
| @@ -37,7 +37,6 @@ final class NodaTimeSplitterTest extends TestCase { | ||||
|         self::assertEquals($output->toTimeName(), "02.01.2020"); | ||||
|         self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020); | ||||
|  | ||||
|  | ||||
|         $output = NodaTimeSplitter::attempt_splitting("02.1.25 v. Chr"); | ||||
|         self::assertNotEmpty($output); | ||||
|         self::assertEquals($output->toOldFormat(), [ | ||||
|   | ||||
| @@ -12,8 +12,6 @@ use PHPUnit\Framework\Attributes\Small; | ||||
|  | ||||
| /** | ||||
|  * This script contains tests for the validation of single field contents. | ||||
|  * | ||||
|  * @covers \NodaValidationHelper | ||||
|  */ | ||||
| #[small] | ||||
| #[CoversClass(\NodaValidationHelper::class)] | ||||
|   | ||||
| @@ -20,6 +20,5 @@ declare(strict_types = 1); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user