1 | <?php |
||
10 | class CsvWriter extends AbstractCsv |
||
11 | { |
||
12 | /** |
||
13 | * |
||
14 | * Default Excel Writing configuration |
||
15 | * |
||
16 | * available options : |
||
17 | * - delimiter : (default = ';') |
||
18 | * - enclosure : (default = '"') |
||
19 | * - encoding : (default = 'CP1252') |
||
20 | * - eol : (default = "\r\n") |
||
21 | * - escape : (default = "\\") |
||
22 | * - first_row_header : (default = false) use the PHP keys as CSV headers and write the first row with them |
||
23 | * - bom : (default = false) add UTF8 BOM marker |
||
24 | * - translit : (default = 'translit') iconv translit option possible values : 'translit', 'ignore', null |
||
25 | * - trim : (default = false) trim each values on each line |
||
26 | * |
||
27 | * N.B. : Be careful, the option 'trim' decrease significantly the performances |
||
28 | * |
||
29 | * @param array $options Dialect Options to describe CSV file parameters |
||
30 | */ |
||
31 | 19 | public function __construct($options = []) |
|
37 | |||
38 | 2 | protected function getCompatibleFileHanderModes() |
|
42 | |||
43 | /** |
||
44 | * open a csv file to write |
||
45 | * |
||
46 | * @param string|resource $file filename or stream resource, default = null |
||
47 | * @return AbstractCsv |
||
48 | */ |
||
49 | 12 | public function open($file = null) |
|
56 | |||
57 | /** |
||
58 | * get HTTP headers for streaming CSV file |
||
59 | * |
||
60 | * @param string $filename |
||
61 | * @return array |
||
62 | */ |
||
63 | 1 | public function getHttpHeaders($filename) |
|
70 | |||
71 | /** |
||
72 | * echo HTTP headers for streaming CSV file |
||
73 | * |
||
74 | * @param string $filename |
||
75 | * |
||
76 | * @codeCoverageIgnore this cannot be tested correctly by PHPUnit because it send HTTP headers |
||
77 | */ |
||
78 | public function createHttpHeaders($filename) |
||
85 | |||
86 | /** |
||
87 | * |
||
88 | * @param resource|null $fileHandler |
||
89 | * @param array $values |
||
90 | * |
||
91 | * @return CsvWriter |
||
92 | * |
||
93 | * @throws \InvalidArgumentException |
||
94 | */ |
||
95 | 13 | protected function write($fileHandler, $values) |
|
144 | |||
145 | /** |
||
146 | * write a CSV row from a PHP array |
||
147 | * |
||
148 | * @param array $values |
||
149 | * |
||
150 | * @return CsvWriter |
||
151 | */ |
||
152 | 14 | public function writeRow(array $values) |
|
163 | |||
164 | /** |
||
165 | * write CSV rows from a PHP arrays |
||
166 | * |
||
167 | * @param array rows (multiple arrays of values) |
||
168 | * |
||
169 | * @return CsvWriter |
||
170 | */ |
||
171 | 6 | public function writeRows(array $rows) |
|
179 | } |
||
180 |