1 | <?php |
||
8 | class IteratorFileCsv extends AbstractIteratorFile implements IteratorInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var array|null |
||
12 | */ |
||
13 | protected $headers; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $delimiter; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $enclosure; |
||
24 | |||
25 | /** |
||
26 | * @var string|null |
||
27 | */ |
||
28 | protected $escape; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $defaults = array(); |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $replace = array(); |
||
39 | |||
40 | const DELIMITER_DEFAULT = ';'; |
||
41 | const ENCLOSURE_DEFAULT = '"'; |
||
42 | |||
43 | /** |
||
44 | * Abre o arquivo para leitura e define a variaveis |
||
45 | * |
||
46 | * @param string $fileName File Name |
||
47 | * @param string $headers Headers [optional] |
||
48 | * @param string $delimiter Separator Fields [optional] |
||
49 | * @param string $enclosure Enclosure Fields [optional] |
||
50 | * @param string $escape String de Escape [optional] |
||
51 | * |
||
52 | * @throws \RuntimeException |
||
53 | */ |
||
54 | 4 | public function __construct( |
|
68 | |||
69 | /** |
||
70 | * Line to array |
||
71 | * |
||
72 | * @return array|null |
||
73 | */ |
||
74 | 1 | private function rowArray() |
|
86 | |||
87 | /** |
||
88 | * Make Row Current |
||
89 | * |
||
90 | 1 | * @return array|bool |
|
91 | */ |
||
92 | 1 | public function makeCurrent() |
|
124 | |||
125 | /** |
||
126 | 1 | * Conta as linhas pulando o cabeçalho, se existir |
|
127 | * |
||
128 | 1 | * @return integer |
|
129 | 1 | */ |
|
130 | 1 | public function count() |
|
139 | |||
140 | 2 | /** |
|
141 | * Rewind na segunda linha |
||
142 | 2 | * |
|
143 | 2 | * @see FileIterator::rewind() |
|
144 | 2 | * @return void |
|
145 | 2 | */ |
|
146 | public function rewind() |
||
152 | |||
153 | /** |
||
154 | * Retorna o headers tendo como chave a posicao das colunas da planilha |
||
155 | 2 | * |
|
156 | * @return array |
||
157 | 2 | */ |
|
158 | 2 | public function getHeaders() |
|
178 | |||
179 | /** |
||
180 | * Set Headers |
||
181 | 4 | * |
|
182 | * @param array $headers Headers |
||
183 | 4 | * |
|
184 | 4 | * @return IteratorFileCsv |
|
185 | */ |
||
186 | public function setHeaders(array $headers) |
||
191 | |||
192 | /** |
||
193 | * Set Fields Defaults |
||
194 | 1 | * |
|
195 | * @param array $defaults Defaults |
||
196 | 1 | * |
|
197 | 1 | * @return void |
|
198 | */ |
||
199 | public function setDefaults(array $defaults) |
||
204 | |||
205 | /** |
||
206 | * Set Fields Replace |
||
207 | 1 | * |
|
208 | * @param array $replace Replaces |
||
209 | 1 | * |
|
210 | 1 | * @return void |
|
211 | */ |
||
212 | public function setReplace(array $replace) |
||
217 | } |
||
218 |