From ec440fb6a79bcdc80012c93c9bd8abb46491dfa7 Mon Sep 17 00:00:00 2001 From: Mihail Date: Wed, 9 Dec 2015 15:11:20 +0200 Subject: [PATCH] add supported extension function --- lib/Parser.php | 5 +++++ lib/TableParser.php | 5 +++-- lib/XlsxParser.php | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Parser.php b/lib/Parser.php index 2aca70f..5cd4d04 100644 --- a/lib/Parser.php +++ b/lib/Parser.php @@ -92,6 +92,11 @@ abstract class Parser } + public final static function supportedExtension() + { + return ['csv','xml','xlsx','txt']; + } + protected function cleanUp( ) { diff --git a/lib/TableParser.php b/lib/TableParser.php index abcbfcf..9ae45e6 100644 --- a/lib/TableParser.php +++ b/lib/TableParser.php @@ -9,6 +9,8 @@ namespace yii\multiparser; +use common\components\CustomVarDamp; + abstract class TableParser extends Parser { @@ -69,8 +71,8 @@ abstract class TableParser extends Parser if ($this->isEmptyRow()) { //счетчик пустых строк - //CustomVarDamp::dump($this->current_row_number); $empty_lines++; + $this->current_row_number++; continue; } @@ -99,7 +101,6 @@ abstract class TableParser extends Parser $empty_lines = 0; } - } /** diff --git a/lib/XlsxParser.php b/lib/XlsxParser.php index d32dfef..bd0afd0 100644 --- a/lib/XlsxParser.php +++ b/lib/XlsxParser.php @@ -37,7 +37,7 @@ class XlsxParser extends TableParser protected $current_sheet; // глубина округления для флоата - // @todo - перенести вродительский класс и применить в дочерних классах + // @todo - перенести в родительский класс и применить в дочерних классах protected $float_precision = 6; public function setup() @@ -208,7 +208,7 @@ class XlsxParser extends TableParser $is_empty = false; - if (!count($this->row) || !$this->current_node->valid()) { + if (!count($this->row)) { return true; } @@ -230,7 +230,7 @@ class XlsxParser extends TableParser protected function isEmptyColumn($val) { - return $val == ''; + return $val == '' || $val === null; } protected function setResult() -- libgit2 0.21.4