1 | <?php |
||
18 | class CSVWriter extends AbstractSendableWriter |
||
19 | { |
||
20 | const SEPARATOR_TAB = "\t"; |
||
21 | const SEPARATOR_COMMA = ','; |
||
22 | const SEPARATOR_SEMICOLON = ';'; |
||
23 | const SEPARATOR_NEWLINE_UNIX = "\n"; |
||
24 | const SEPARATOR_NEWLINE_WIN = "\r\n"; |
||
25 | |||
26 | /** |
||
27 | * @var SimpleHeaders |
||
28 | */ |
||
29 | protected $headers; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $options = [ |
||
35 | 'field_separator' => ';', |
||
36 | 'line_separator' => "\n", |
||
37 | 'enclosure' => '', |
||
38 | 'charset' => 'UTF-8', |
||
39 | 'escape' => '\\', |
||
40 | // ignore charset transliteration errors |
||
41 | 'ignore_translit_error' => false |
||
42 | ]; |
||
43 | |||
44 | /** |
||
45 | * @throws Exception\CharsetConversionException |
||
46 | * |
||
47 | * @param Options $options |
||
48 | * |
||
49 | * @return string csv encoded data |
||
50 | */ |
||
51 | 6 | public function getData(Options $options = null) |
|
136 | |||
137 | /** |
||
138 | * @param string $item |
||
139 | */ |
||
140 | 5 | protected function escapeLineDelimiter(&$item) |
|
145 | |||
146 | /** |
||
147 | * @param string $item |
||
148 | */ |
||
149 | 2 | protected function escapeTabDelimiter(&$item) |
|
153 | |||
154 | /** |
||
155 | * @param string $item |
||
156 | */ |
||
157 | 3 | protected function escapeFieldDelimiter(&$item) |
|
161 | |||
162 | /** |
||
163 | * @param string $item |
||
164 | * @param string $key |
||
165 | */ |
||
166 | 3 | protected function addEnclosure(&$item, $key) |
|
|
|||
167 | { |
||
168 | 3 | $enc = $this->options['enclosure']; |
|
169 | 3 | $escape = $this->options['escape']; |
|
170 | 3 | if ($escape === '') { |
|
171 | $item = $enc . str_replace($enc, '', $item) . $enc; |
||
172 | } else { |
||
173 | 3 | $item = $enc . str_replace($enc, $escape . $enc, $item) . $enc; |
|
174 | } |
||
175 | 3 | } |
|
176 | |||
177 | /** |
||
178 | * Return default headers for sending store data via http. |
||
179 | * |
||
180 | * @return SimpleHeaders |
||
181 | */ |
||
182 | 3 | public function getHttpHeaders() |
|
192 | } |
||
193 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.