Files
core/src/MigrateImport/JudgeMe/JudgeMeCsvReader.php
T

30 lines
596 B
PHP

<?php
namespace Modules\Core\MigrateImport\JudgeMe;
class JudgeMeCsvReader
{
/**
* @return array<int, array<string, string>>
*/
public function read(string $csvPath): array
{
$handle = fopen($csvPath, 'r');
if ($handle === false) {
throw new \RuntimeException("Could not open CSV file: {$csvPath}");
}
$headers = fgetcsv($handle);
$rows = [];
while (($row = fgetcsv($handle)) !== false) {
$rows[] = array_combine($headers, $row);
}
fclose($handle);
return $rows;
}
}