Remove redundant $key_type assignments in xlvask_customer.php for cleaner and more concise code

This commit is contained in:
Jepp9350
2025-06-03 12:58:33 +02:00
parent 79469914ec
commit 5e9f0ade22
@@ -231,7 +231,6 @@ class xlvask_customer
case $this->default_string:
case $this->default_string_nullable:
$nullable = $default_property_values[$key] === $this->default_string_nullable;
$key_type = 'string'; // Convert to string if it matches the default string
// Check if the value is a string or can be converted to a string
if (is_string($value) || is_numeric($value)) {
$value = (string)$value; // Ensure the value is a string
@@ -244,14 +243,12 @@ class xlvask_customer
case $this->default_int:
case $this->default_int_nullable:
$nullable = $default_property_values[$key] === $this->default_int_nullable;
$key_type = 'integer'; // Convert to integer if it matches the default int
// Check if the value is numeric and convert it to an integer or null
$value = is_numeric($value) ? (int)$value : ($nullable ? null : 0); // Ensure the value is an integer or null
break;
case $this->default_bool:
case $this->default_bool_nullable:
$nullable = $default_property_values[$key] === $this->default_bool_nullable;
$key_type = 'boolean'; // Convert to boolean if it matches the default bool
// Check if the value is a boolean or can be converted to a boolean
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
if ($value === null && !$nullable) {
@@ -259,7 +256,6 @@ class xlvask_customer
}
break;
case null:
$key_type = null; // If the type is null, keep it as is
break;
default:
// If the value is not a default string, keep it as is