1 | <?php |
||
15 | class Writer extends AbstractWriter |
||
16 | { |
||
17 | /** Number of rows to write before flushing */ |
||
18 | const FLUSH_THRESHOLD = 500; |
||
19 | |||
20 | /** @var string Content-Type value for the header */ |
||
21 | protected static $headerContentType = 'text/csv; charset=UTF-8'; |
||
22 | |||
23 | /** @var string Defines the character used to delimit fields (one character only) */ |
||
24 | protected $fieldDelimiter = ','; |
||
25 | |||
26 | /** @var string Defines the character used to enclose fields (one character only) */ |
||
27 | protected $fieldEnclosure = '"'; |
||
28 | |||
29 | /** @var int */ |
||
30 | protected $lastWrittenRowIndex = 0; |
||
31 | |||
32 | /** |
||
33 | * Sets the field delimiter for the CSV |
||
34 | * |
||
35 | * @api |
||
36 | * @param string $fieldDelimiter Character that delimits fields |
||
37 | * @return Writer |
||
38 | */ |
||
39 | public function setFieldDelimiter($fieldDelimiter) |
||
44 | |||
45 | /** |
||
46 | * Sets the field enclosure for the CSV |
||
47 | * |
||
48 | * @api |
||
49 | * @param string $fieldEnclosure Character that enclose fields |
||
50 | * @return Writer |
||
51 | */ |
||
52 | public function setFieldEnclosure($fieldEnclosure) |
||
57 | |||
58 | /** |
||
59 | * Opens the CSV streamer and makes it ready to accept data. |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | protected function openWriter() |
||
68 | |||
69 | /** |
||
70 | * Adds data to the currently opened writer. |
||
71 | * |
||
72 | * @param array $dataRow Array containing data to be written. |
||
73 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
74 | * @param \Box\Spout\Writer\Style\Style $style Ignored here since CSV does not support styling. |
||
75 | * @return void |
||
76 | * @throws \Box\Spout\Common\Exception\IOException If unable to write data |
||
77 | */ |
||
78 | protected function addRowToWriter(array $dataRow, $style) |
||
90 | |||
91 | /** |
||
92 | * Closes the CSV streamer, preventing any additional writing. |
||
93 | * If set, sets the headers and redirects output to the browser. |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | protected function closeWriter() |
||
101 | } |
||
102 |