1 | <?php |
||
16 | class Writer extends AbstractWriter |
||
17 | { |
||
18 | /** Number of rows to write before flushing */ |
||
19 | const FLUSH_THRESHOLD = 500; |
||
20 | |||
21 | /** @var string Content-Type value for the header */ |
||
22 | protected static $headerContentType = 'text/csv; charset=UTF-8'; |
||
23 | |||
24 | /** @var int */ |
||
25 | protected $lastWrittenRowIndex = 0; |
||
26 | |||
27 | /** |
||
28 | * Sets the field delimiter for the CSV |
||
29 | * |
||
30 | * @api |
||
31 | * @param string $fieldDelimiter Character that delimits fields |
||
32 | * @return Writer |
||
33 | */ |
||
34 | 8 | public function setFieldDelimiter($fieldDelimiter) |
|
39 | |||
40 | /** |
||
41 | * Sets the field enclosure for the CSV |
||
42 | * |
||
43 | * @api |
||
44 | * @param string $fieldEnclosure Character that enclose fields |
||
45 | * @return Writer |
||
46 | */ |
||
47 | 8 | public function setFieldEnclosure($fieldEnclosure) |
|
52 | |||
53 | /** |
||
54 | * Set if a BOM has to be added to the file |
||
55 | * |
||
56 | * @api |
||
57 | * @param bool $shouldAddBOM |
||
58 | * @return Writer |
||
59 | */ |
||
60 | 8 | public function setShouldAddBOM($shouldAddBOM) |
|
65 | |||
66 | /** |
||
67 | * Opens the CSV streamer and makes it ready to accept data. |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | 9 | protected function openWriter() |
|
78 | |||
79 | /** |
||
80 | * Adds data to the currently opened writer. |
||
81 | * |
||
82 | * @param array $dataRow Array containing data to be written. |
||
83 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
84 | * @param \Box\Spout\Writer\Style\Style $style Ignored here since CSV does not support styling. |
||
85 | * @return void |
||
86 | * @throws \Box\Spout\Common\Exception\IOException If unable to write data |
||
87 | */ |
||
88 | 8 | protected function addRowToWriter(array $dataRow, $style) |
|
103 | |||
104 | /** |
||
105 | * Closes the CSV streamer, preventing any additional writing. |
||
106 | * If set, sets the headers and redirects output to the browser. |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | 9 | protected function closeWriter() |
|
114 | } |
||
115 |