feat: add administration reporting and correction services
This commit is contained in:
@@ -44,6 +44,21 @@ final class CsvExporter
|
||||
return $withBom ? self::UTF8_BOM . $csv : $csv;
|
||||
}
|
||||
|
||||
/** Serialize an allow-listed report projection without exposing associative keys. */
|
||||
public function exportRecords(array $records, bool $withBom = false): string
|
||||
{
|
||||
if ($records === []) return $withBom ? self::UTF8_BOM : '';
|
||||
$headers = array_keys($records[0]);
|
||||
$rows = [];
|
||||
foreach ($records as $record) {
|
||||
if (!is_array($record) || array_keys($record) !== $headers) {
|
||||
throw new InvalidArgumentException('CSV report records must share the same ordered fields.');
|
||||
}
|
||||
$rows[] = array_values($record);
|
||||
}
|
||||
return $this->export($headers, $rows, $withBom);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<mixed> $fields
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user