Improve type-safety / explicitness

This commit is contained in:
Joshua Ramon Enslin 2020-09-21 10:49:34 +02:00 committed by Stefan Rohde-Enslin
parent e4558ae227
commit dd2fbafd25
2 changed files with 4 additions and 4 deletions

View File

@ -166,7 +166,7 @@ final class NodaTimeAutotranslater {
if (intval($zeit_ende) >= 0 && intval($zeit_beginn) < 0) { if (intval($zeit_ende) >= 0 && intval($zeit_beginn) < 0) {
return self::TRANSLATABLE_NOT; return self::TRANSLATABLE_NOT;
} }
if (intval($zeit_ende) < 1000 || intval($zeit_ende) < 0 && intval($zeit_beginn) < 0) { if (intval($zeit_ende) < 0 && intval($zeit_beginn) < 0 || intval($zeit_ende) < 1000) {
return self::TRANSLATABLE_AS_YEAR_WITH_SUFFIX; return self::TRANSLATABLE_AS_YEAR_WITH_SUFFIX;
} }
// Conditions speaking against translatability. // Conditions speaking against translatability.
@ -235,7 +235,7 @@ final class NodaTimeAutotranslater {
*/ */
public function translate(array $timeInfo):void { public function translate(array $timeInfo):void {
if (!($translation_type = self::check_translatability($timeInfo['zeit_beginn'], $timeInfo['zeit_ende'], (string)$timeInfo['zeit_zaehlzeit_monat']))) { if (!($translation_type = self::check_translatability((string)$timeInfo['zeit_beginn'], (string)$timeInfo['zeit_ende'], (string)$timeInfo['zeit_zaehlzeit_monat']))) {
throw new MDgenericInvalidInputsException("Non-translatable date"); throw new MDgenericInvalidInputsException("Non-translatable date");
} }

View File

@ -195,10 +195,10 @@ final class NodaTimeSplitter {
else if (intval($moda[2]) !== 0 and intval($moda[3]) !== 0) { else if (intval($moda[2]) !== 0 and intval($moda[3]) !== 0) {
return "{$moda[3]}.{$moda[2]}.{$moda[0]}{$suffix}"; return "{$moda[3]}.{$moda[2]}.{$moda[0]}{$suffix}";
} }
else if ($moda[0] === $moda[1] && trim($moda[2], " 0") === "" && trim($moda[3], " 0") === "") { else if ($moda[0] === $moda[1] && trim((string)$moda[2], " 0") === "" && trim((string)$moda[3], " 0") === "") {
return "{$moda[0]}{$suffix}"; return "{$moda[0]}{$suffix}";
} }
else if ($moda[0] === $moda[1] && trim($moda[2], " 0") !== "" && trim($moda[3], " 0") === "") { else if ($moda[0] === $moda[1] && trim((string)$moda[2], " 0") !== "" && trim((string)$moda[3], " 0") === "") {
setlocale(LC_TIME, NodaTimeAutotranslater::LANGS_TO_LOCALES['de']); setlocale(LC_TIME, NodaTimeAutotranslater::LANGS_TO_LOCALES['de']);
return strftime(getMonthFormatByLang("de"), MD_STD::strtotime("{$moda[0]}-{$moda[2]}-01 01:01:01")) . $suffix; return strftime(getMonthFormatByLang("de"), MD_STD::strtotime("{$moda[0]}-{$moda[2]}-01 01:01:01")) . $suffix;
} }