Improve type-safety
This commit is contained in:
@ -10,7 +10,7 @@ require_once __DIR__ . '/inc/datesByCountry.php';
|
||||
/**
|
||||
* Autotranslater class for times.
|
||||
*/
|
||||
class NodaTimeAutotranslater {
|
||||
final class NodaTimeAutotranslater {
|
||||
|
||||
const USECASE_MONTH = 1;
|
||||
const USECASE_DAY = 2;
|
||||
@ -74,11 +74,11 @@ class NodaTimeAutotranslater {
|
||||
*/
|
||||
public function translate(array $timeInfo):void {
|
||||
|
||||
if (!self::check_translatability($timeInfo['zeit_zaehlzeit_monat'])) {
|
||||
if (!self::check_translatability((string)$timeInfo['zeit_zaehlzeit_monat'])) {
|
||||
throw new MDgenericInvalidInputsException("Non-translatable date");
|
||||
}
|
||||
|
||||
if (trim($timeInfo['zeit_zaehlzeit_tag'], ", .0") === "") {
|
||||
if (trim((string)$timeInfo['zeit_zaehlzeit_tag'], ", .0") === "") {
|
||||
$dateStr = "{$timeInfo['zeit_zaehlzeit_jahr']}-{$timeInfo['zeit_zaehlzeit_monat']}-05 00:00:01";
|
||||
$usecase = self::USECASE_MONTH;
|
||||
}
|
||||
@ -94,7 +94,10 @@ class NodaTimeAutotranslater {
|
||||
setlocale(LC_TIME, $locale);
|
||||
if ($locale !== setlocale(LC_TIME, "0")) continue;
|
||||
if ($usecase === self::USECASE_MONTH) $tLangValue = strftime(getMonthFormatByLang($tLang), $dateGeneral ?: 0);
|
||||
else if ($usecase === self::USECASE_DAY) $tLangValue = strftime(getDateFormatByLang($tLang), $dateGeneral ?: 0);
|
||||
else { # if ($usecase === self::USECASE_DAY)
|
||||
$tLangValue = strftime(getDateFormatByLang($tLang), $dateGeneral ?: 0);
|
||||
}
|
||||
|
||||
$this->_insertStmt->bind_param("iss", $this->_znum, $tLang, $tLangValue);
|
||||
$this->_insertStmt->execute();
|
||||
|
||||
|
Reference in New Issue
Block a user