diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2015-03-18 21:24:19 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2015-03-18 21:24:19 +0100 |
| commit | 66c6199f15d22b2dcc467e7afd12395bce280190 (patch) | |
| tree | cfd23da44aecef2842dc79ea6c4e6e04fa936b7c /src | |
| parent | c6414fc745ef7d2bb6d1e6cca59bbd5212179542 (diff) | |
| download | bdrem-66c6199f15d22b2dcc467e7afd12395bce280190.tar.gz bdrem-66c6199f15d22b2dcc467e7afd12395bce280190.zip | |
Catch CSV errorsv0.6.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/bdrem/Source/Csv.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bdrem/Source/Csv.php b/src/bdrem/Source/Csv.php index 62cf777..f1c4048 100644 --- a/src/bdrem/Source/Csv.php +++ b/src/bdrem/Source/Csv.php @@ -109,6 +109,7 @@ class Source_Csv } $first = true; + $arEvents = array(); while (($row = fgetcsv($handle, 1000, $this->separator)) !== false) { if ($first && $this->firstLineIsHeader) { $first = false; @@ -118,9 +119,15 @@ class Source_Csv if ($this->columns['event'] === false) { $eventType = $this->defaultEvent; } else { + if (!isset($row[$this->columns['event']])) { + throw new \Exception('Event column does not exist in CSV'); + } $eventType = $row[$this->columns['event']]; } + if (!isset($row[$this->columns['date']])) { + throw new \Exception('Date column does not exist in CSV'); + } if ($row[$this->columns['date']] == '') { continue; } @@ -132,6 +139,10 @@ class Source_Csv ) ); + if (!isset($row[$this->columns['name']])) { + throw new \Exception('Name column does not exist in CSV'); + } + $event = new Event( (string) $row[$this->columns['name']], $eventType, |
