add isNumericType() и convertNumericFormat()

This commit is contained in:
Mikhail Chusavitin
2026-01-21 12:36:37 +03:00
parent 4573a8c56f
commit d21da6d49e

View File

@@ -544,7 +544,51 @@ private function formatRowData(array $rowData): string
// Если не удалось распарсить - возвращаем как есть // Если не удалось распарсить - возвращаем как есть
return $date; return $date;
} }
// ✅ ДОБАВЬТЕ ЭТИ ДВА МЕТОДА СЮДА:
private function isNumericType(string $dataType): bool
{
$numericTypes = [
'int', 'tinyint', 'smallint', 'mediumint', 'bigint',
'decimal', 'float', 'double', 'numeric', 'real'
];
$dataType = strtolower($dataType);
foreach ($numericTypes as $type) {
if (str_contains($dataType, $type)) {
return true;
}
}
return false;
}
private function convertNumericFormat($value)
{
if ($value === null || $value === '') {
return null;
}
$value = trim((string)$value);
$value = str_replace(' ', '', $value);
if (strpos($value, ',') === false) {
return is_numeric($value) ? $value : null;
}
$lastCommaPos = strrpos($value, ',');
$lastDotPos = strrpos($value, '.');
if ($lastCommaPos > $lastDotPos) {
$value = str_replace('.', '', $value);
$value = str_replace(',', '.', $value);
} else {
$value = str_replace(',', '', $value);
}
return is_numeric($value) ? $value : null;
}
public function exportCSV( public function exportCSV(
string $schema, string $schema,
string $table, string $table,