From dd2fbafd25c1cff8ad8705ab14e5f529cbffbe0f Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 21 Sep 2020 10:49:34 +0200 Subject: [PATCH] Improve type-safety / explicitness --- src/NodaTimeAutotranslater.php | 4 ++-- src/NodaTimeSplitter.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NodaTimeAutotranslater.php b/src/NodaTimeAutotranslater.php index e0f7276..8f27a2b 100644 --- a/src/NodaTimeAutotranslater.php +++ b/src/NodaTimeAutotranslater.php @@ -166,7 +166,7 @@ final class NodaTimeAutotranslater { if (intval($zeit_ende) >= 0 && intval($zeit_beginn) < 0) { 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; } // Conditions speaking against translatability. @@ -235,7 +235,7 @@ final class NodaTimeAutotranslater { */ 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"); } diff --git a/src/NodaTimeSplitter.php b/src/NodaTimeSplitter.php index 94b2d4d..b692f99 100644 --- a/src/NodaTimeSplitter.php +++ b/src/NodaTimeSplitter.php @@ -195,10 +195,10 @@ final class NodaTimeSplitter { else if (intval($moda[2]) !== 0 and intval($moda[3]) !== 0) { 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}"; } - 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']); return strftime(getMonthFormatByLang("de"), MD_STD::strtotime("{$moda[0]}-{$moda[2]}-01 01:01:01")) . $suffix; }