Skip to content

Commit 4a7b9df

Browse files
Merge pull request #7 from terdelyi/master
Fixed line_number variable, Errors method
2 parents f01ec3a + 2f2a28a commit 4a7b9df

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.DS_Store

-6 KB
Binary file not shown.

src/SoapBox/Formatter/Formatter.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,12 @@ protected function _from_csv($string, $attributes = array()) {
368368
// Get the headings
369369
$headings = str_replace($escape.$enclosure, $enclosure, str_getcsv(array_shift($rows), $delimiter, $enclosure, $escape));
370370

371-
foreach ($rows as $row) {
371+
foreach ($rows as $line_number => $row) {
372372
$data_fields = str_replace($escape.$enclosure, $enclosure, str_getcsv($row, $delimiter, $enclosure, $escape));
373373
if (count($data_fields) > count($headings)) {
374-
array_push(self::$errors, Lang::get('formatter::formatter.more_data', array('line_number' => $line_number ) ));
374+
array_push(self::$errors, Lang::get('formatter::formatter.more_data', array('line_number' => $line_number + 1) ));
375375
} else if (count($data_fields) < count($headings)) {
376-
array_push(self::$errors, Lang::get('formatter::formatter.less_data', array('line_number' => $line_number ) ));
376+
array_push(self::$errors, Lang::get('formatter::formatter.less_data', array('line_number' => $line_number + 1) ));
377377
} else {
378378
$data[] = array_combine($headings, $data_fields);
379379
}
@@ -419,4 +419,13 @@ public static function is_assoc($arr) {
419419
}
420420
return false;
421421
}
422+
423+
/**
424+
* Returns with errors
425+
* @return array
426+
*/
427+
public function errors()
428+
{
429+
return self::$errors;
430+
}
422431
}

0 commit comments

Comments
 (0)