function parse_metadata_file(string $path): array { $metadata = []; $content = file_get_contents($path); if ($content === false) { return []; } $content = convert_to_utf8($content); $lines = preg_split('/\R/u', $content) ?: []; foreach ($lines as $line) { if (trim($line) === '') { continue; } [$key, $value] = array_pad(explode('=', $line, 2), 2, ''); $key = trim($key); $value = trim($value); if ($key !== '') { $metadata[$key] = $value; } } return $metadata; }