From 2f2a28a3ef74a7112a073424ce315a2d969d102b Mon Sep 17 00:00:00 2001 From: Tamas Erdelyi Date: Thu, 10 Apr 2014 13:03:00 +0200 Subject: [PATCH] Fixed line_number variable, Errors method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Variable line_number declaration was missing in method _from_csv. Now it gets the key number of $row and add 1 to equal the correct line number. I also created a separate errors() method to get errors from the object, because getting the static variable couldn’t work for me. --- .DS_Store | Bin 6148 -> 0 bytes src/SoapBox/Formatter/Formatter.php | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 $row) { $data_fields = str_replace($escape.$enclosure, $enclosure, str_getcsv($row, $delimiter, $enclosure, $escape)); if (count($data_fields) > count($headings)) { - array_push(self::$errors, Lang::get('formatter::formatter.more_data', array('line_number' => $line_number ) )); + array_push(self::$errors, Lang::get('formatter::formatter.more_data', array('line_number' => $line_number + 1) )); } else if (count($data_fields) < count($headings)) { - array_push(self::$errors, Lang::get('formatter::formatter.less_data', array('line_number' => $line_number ) )); + array_push(self::$errors, Lang::get('formatter::formatter.less_data', array('line_number' => $line_number + 1) )); } else { $data[] = array_combine($headings, $data_fields); } @@ -419,4 +419,13 @@ public static function is_assoc($arr) { } return false; } + + /** + * Returns with errors + * @return array + */ + public function errors() + { + return self::$errors; + } }