Commit ec440fb6a79bcdc80012c93c9bd8abb46491dfa7
1 parent
0aca931b
add supported extension function
Showing
3 changed files
with
11 additions
and
5 deletions
Show diff stats
lib/Parser.php
@@ -92,6 +92,11 @@ abstract class Parser | @@ -92,6 +92,11 @@ abstract class Parser | ||
92 | 92 | ||
93 | } | 93 | } |
94 | 94 | ||
95 | + public final static function supportedExtension() | ||
96 | + { | ||
97 | + return ['csv','xml','xlsx','txt']; | ||
98 | + } | ||
99 | + | ||
95 | protected function cleanUp( ) | 100 | protected function cleanUp( ) |
96 | { | 101 | { |
97 | 102 |
lib/TableParser.php
@@ -9,6 +9,8 @@ | @@ -9,6 +9,8 @@ | ||
9 | namespace yii\multiparser; | 9 | namespace yii\multiparser; |
10 | 10 | ||
11 | 11 | ||
12 | +use common\components\CustomVarDamp; | ||
13 | + | ||
12 | abstract class TableParser extends Parser | 14 | abstract class TableParser extends Parser |
13 | { | 15 | { |
14 | 16 | ||
@@ -69,8 +71,8 @@ abstract class TableParser extends Parser | @@ -69,8 +71,8 @@ abstract class TableParser extends Parser | ||
69 | 71 | ||
70 | if ($this->isEmptyRow()) { | 72 | if ($this->isEmptyRow()) { |
71 | //счетчик пустых строк | 73 | //счетчик пустых строк |
72 | - //CustomVarDamp::dump($this->current_row_number); | ||
73 | $empty_lines++; | 74 | $empty_lines++; |
75 | + $this->current_row_number++; | ||
74 | continue; | 76 | continue; |
75 | } | 77 | } |
76 | 78 | ||
@@ -99,7 +101,6 @@ abstract class TableParser extends Parser | @@ -99,7 +101,6 @@ abstract class TableParser extends Parser | ||
99 | $empty_lines = 0; | 101 | $empty_lines = 0; |
100 | 102 | ||
101 | } | 103 | } |
102 | - | ||
103 | } | 104 | } |
104 | 105 | ||
105 | /** | 106 | /** |
lib/XlsxParser.php
@@ -37,7 +37,7 @@ class XlsxParser extends TableParser | @@ -37,7 +37,7 @@ class XlsxParser extends TableParser | ||
37 | protected $current_sheet; | 37 | protected $current_sheet; |
38 | 38 | ||
39 | // глубина округления для флоата | 39 | // глубина округления для флоата |
40 | - // @todo - перенести вродительский класс и применить в дочерних классах | 40 | + // @todo - перенести в родительский класс и применить в дочерних классах |
41 | protected $float_precision = 6; | 41 | protected $float_precision = 6; |
42 | 42 | ||
43 | public function setup() | 43 | public function setup() |
@@ -208,7 +208,7 @@ class XlsxParser extends TableParser | @@ -208,7 +208,7 @@ class XlsxParser extends TableParser | ||
208 | 208 | ||
209 | $is_empty = false; | 209 | $is_empty = false; |
210 | 210 | ||
211 | - if (!count($this->row) || !$this->current_node->valid()) { | 211 | + if (!count($this->row)) { |
212 | return true; | 212 | return true; |
213 | } | 213 | } |
214 | 214 | ||
@@ -230,7 +230,7 @@ class XlsxParser extends TableParser | @@ -230,7 +230,7 @@ class XlsxParser extends TableParser | ||
230 | 230 | ||
231 | protected function isEmptyColumn($val) | 231 | protected function isEmptyColumn($val) |
232 | { | 232 | { |
233 | - return $val == ''; | 233 | + return $val == '' || $val === null; |
234 | } | 234 | } |
235 | 235 | ||
236 | protected function setResult() | 236 | protected function setResult() |