@@ -14,6 +14,6 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | public function __invoke($value) |
| 16 | 16 | { |
| 17 | - return (isset($value[$this->fieldName]) and strlen($value[$this->fieldName]) > 0) ; |
|
| 17 | + return (isset($value[$this->fieldName]) and strlen($value[$this->fieldName]) > 0); |
|
| 18 | 18 | } |
| 19 | 19 | } |
@@ -121,15 +121,15 @@ |
||
| 121 | 121 | $this->appendRow(",\n"); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $item = array_reduce($item, function ($outCell, $currentCell) { |
|
| 124 | + $item = array_reduce($item, function($outCell, $currentCell) { |
|
| 125 | 125 | if (is_null($currentCell)) { |
| 126 | 126 | $outCell[] = 'null'; |
| 127 | 127 | |
| 128 | 128 | return $outCell; |
| 129 | 129 | } |
| 130 | 130 | //escape sql string |
| 131 | - $search = ['\\', "\x00", "\n", "\r", "'", '"', "\x1a"]; |
|
| 132 | - $replace = ['\\\\','\\0','\\n', '\\r', "\'", '\"', '\\Z']; |
|
| 131 | + $search = ['\\', "\x00", "\n", "\r", "'", '"', "\x1a"]; |
|
| 132 | + $replace = ['\\\\', '\\0', '\\n', '\\r', "\'", '\"', '\\Z']; |
|
| 133 | 133 | $outCell[] = '"' . str_replace($search, $replace, $currentCell) . '"'; |
| 134 | 134 | |
| 135 | 135 | return $outCell; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | 'header' => true, |
| 50 | 50 | 'delimiter' => "\t", |
| 51 | 51 | ]; |
| 52 | - foreach (['columns','delimiter','enclosure','header','replace_file'] as $option) { |
|
| 52 | + foreach (['columns', 'delimiter', 'enclosure', 'header', 'replace_file'] as $option) { |
|
| 53 | 53 | if (array_key_exists($option, $options)) { |
| 54 | 54 | $opts[$option] = $options[$option]; |
| 55 | 55 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $rowsToIgnore = $this->options['header'] ? 1 : 0; |
| 99 | 99 | $headers = '(' . implode(', ', $this->headers) . ')'; |
| 100 | 100 | |
| 101 | - $delimiter = str_replace(["\t","\n","\r"], ['\\t','\\n','\\r'], $this->options['delimiter']); |
|
| 101 | + $delimiter = str_replace(["\t", "\n", "\r"], ['\\t', '\\n', '\\r'], $this->options['delimiter']); |
|
| 102 | 102 | $enclosure = $this->options['enclosure']; |
| 103 | 103 | |
| 104 | 104 | $createTableSql = null; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $autoIncrementField = $this->options['autoincrement_field'] ? $this->options['autoincrement_field'] . ' int auto_increment not null, ' : ''; |
| 110 | 110 | $primaryKeyField = $this->options['autoincrement_field'] ? ', primary key (' . $this->options['autoincrement_field'] . ')' : ''; |
| 111 | - $createTableSql = sprintf('DROP TABLE IF EXISTS %s;CREATE TABLE %s (%s%s%s);', $this->tableName, $this->tableName, $autoIncrementField, implode(', ', array_map(function ($value) { |
|
| 111 | + $createTableSql = sprintf('DROP TABLE IF EXISTS %s;CREATE TABLE %s (%s%s%s);', $this->tableName, $this->tableName, $autoIncrementField, implode(', ', array_map(function($value) { |
|
| 112 | 112 | return $value . ' text'; |
| 113 | 113 | }, $columnNames)), $primaryKeyField); |
| 114 | 114 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | while (($data = $this->readCurrentRow()) != false) { |
| 48 | 48 | //skip empty rows |
| 49 | - if($data == [null]){ |
|
| 49 | + if ($data == [null]) { |
|
| 50 | 50 | continue; |
| 51 | 51 | } |
| 52 | 52 | if ($headers) { |