/** * @return SSLHistoryDom */ protected function readCSV($filename) { $fp = fopen($filename, 'r'); if ($fp === false) { throw new RuntimeException("Could not open CSV file {$filename}"); } $tracks = array(); $field_order = array('row', 'deck', 'artist', 'title', 'starttime', 'endtime', 'played', 'added', 'updatedAt', 'playtime', 'length'); while (false !== ($fs = fgetcsv($fp))) { if ($fs) { foreach ($field_order as $i => $f_name) { isset($fs[$i]) && ($fields[$f_name] = $fs[$i]); } $track = new SSLTrack(); $track->populateFrom($fields); $tracks[] = $track; } } if (empty($tracks)) { throw new InvalidArgumentException("File {$filename} contained no records"); } fclose($fp); return $tracks; }