extended firefly import options, cleaned up language usage in code, new README in english, changed license references

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Reindl David (IT-PTR-CEN2-SL10)
2026-05-04 00:23:02 +02:00
co-authored by Copilot
parent 90dc37cafc
commit a6ed05a38a
15 changed files with 2064 additions and 1208 deletions
+27 -27
View File
@@ -3,10 +3,10 @@
namespace UbsCsvTransformer;
/**
* Extrahiert Metadaten aus Header-Zeilen mit Regex
* Extracts metadata from header lines using regex
*
* Diese Klasse extrahiert konstante Werte aus den Metadatenzeilen
* (Header-Zeilen vor der eigentlichen CSV-Tabelle) mittels Regex-Regeln.
* Extracts constant values from metadata lines
* (header lines before the actual CSV table) using regex rules.
*/
class MetadataExtractor
{
@@ -18,17 +18,17 @@ class MetadataExtractor
}
/**
* Extrahiert Metadaten aus den übergebenen Zeilen
* Extracts metadata from the provided lines
*
* @param array $lines Array von Zeilen aus dem CSV-Header
* @return array Extrahierte Metadaten
* @param array $lines Array of lines from the CSV header
* @return array Extracted metadata
*/
public function extract(array $lines): array
{
$metadata = [];
foreach ($this->rules as $rule) {
// Validiere erforderliche Felder
// Validate required fields
if (empty($rule['name']) || empty($rule['regex'])) {
continue;
}
@@ -37,15 +37,15 @@ class MetadataExtractor
$lineNumber = $rule['lineNumber'] ?? 1;
$regex = $rule['regex'];
// ✅ KORRIGIERT: Off-by-One Fix
// config.json: "lineNumber": 1, 2, 3 (1-basiert, für Menschen lesbar)
// PHP Arrays: $lines[0], $lines[1], $lines[2] (0-basiert)
// Konvertierung: arrayIndex = lineNumber - 1
// Off-by-one fix
// config.json: "lineNumber": 1, 2, 3 (1-based, human-readable)
// PHP arrays: $lines[0], $lines[1], $lines[2] (0-based)
// Conversion: arrayIndex = lineNumber - 1
$arrayIndex = $lineNumber - 1;
// Prüfe ob Zeile existiert
// Check if line exists
if (!isset($lines[$arrayIndex])) {
// Zeile existiert nicht - Debug-Info für Support
// Line does not exist - debug info for support
DebugLogger::log('metadata_warning', "Extraction rule not found", [
'rule_name' => $ruleName,
'expected_lineNumber' => $lineNumber,
@@ -57,7 +57,7 @@ class MetadataExtractor
$line = $lines[$arrayIndex];
// Regex mit '#' als Delimiter (erlaubt '/' in User-Patterns); '#' im Pattern escapen
// Regex with '#' as delimiter (allows '/' in user patterns); escape '#' in pattern
$pattern = '#' . str_replace('#', '\#', $regex) . '#u';
$matchResult = @preg_match_all($pattern, $line, $matches);
if ($matchResult === false) {
@@ -68,7 +68,7 @@ class MetadataExtractor
continue;
}
if ($matchResult === 0) {
// Regex matched nicht auf dieser Zeile
// Regex did not match on this line
DebugLogger::log('metadata_warning', "Regex did not match", [
'rule_name' => $ruleName,
'lineNumber' => $lineNumber,
@@ -78,20 +78,20 @@ class MetadataExtractor
continue;
}
// ✅ KORRIGIERT: captureGroup benutzen
// captureGroup definiert welche Klammer-Gruppe extrahiert wird
// 0 = komplette Match
// 1 = erste Klammer-Gruppe (...)
// 2 = zweite Klammer-Gruppe, etc.
// Use captureGroup to select the extraction group
// captureGroup defines which capture group is extracted
// 0 = complete match
// 1 = first capture group (...)
// 2 = second capture group, etc.
$captureGroup = isset($rule['captureGroup']) ? intval($rule['captureGroup']) : 1;
// Sicherstellen dass die Capture Group existiert
// Ensure the capture group exists
if (!isset($matches[$captureGroup]) || empty($matches[$captureGroup])) {
// Fallback: Nutze komplette Match wenn Gruppe nicht existiert
// Fallback: use complete match if group does not exist
$metadata[$ruleName] = $matches[0][0] ?? '';
// echo "DEBUG: extraction_rule '{$ruleName}' - captureGroup {$captureGroup} not found, falling back to complete match\n";
} else {
// Nutze die spezifische Capture Group
// Use the specific capture group
$metadata[$ruleName] = $matches[$captureGroup][0] ?? '';
}
@@ -105,9 +105,9 @@ class MetadataExtractor
}
/**
* Gibt die Anzahl der definierten Extraction-Rules zurück
* Returns the number of defined extraction rules
*
* @return int Anzahl Rules
* @return int Number of rules
*/
public function getRuleCount(): int
{
@@ -115,9 +115,9 @@ class MetadataExtractor
}
/**
* Gibt alle definierten Extraction-Rules zurück
* Returns all defined extraction rules
*
* @return array Die Rules
* @return array The rules
*/
public function getRules(): array
{