1 | <?php |
||
13 | class Reader extends AbstractCsv implements \Iterator, \Countable |
||
14 | { |
||
15 | public static $defaultFormatter = StringFormatter::class; |
||
16 | |||
17 | protected $fopenMode = 'r'; |
||
18 | /** @var FormatterInterface[] */ |
||
19 | protected $formatters = []; |
||
20 | /** @var int */ |
||
21 | protected $index = 0; |
||
22 | /** @var Row */ |
||
23 | protected $headers; |
||
24 | /** @var Row */ |
||
25 | protected $row; |
||
26 | /** @var string */ |
||
27 | protected $escapeCharacter = "\0"; |
||
28 | |||
29 | /** |
||
30 | * @param $file |
||
31 | * |
||
32 | * @return Reader |
||
33 | */ |
||
34 | public static function read($file) |
||
40 | |||
41 | /** |
||
42 | * @return Row |
||
43 | */ |
||
44 | public function getHeaders() |
||
48 | |||
49 | 3 | public function getHeader($key) |
|
57 | |||
58 | /** |
||
59 | * @param mixed $key |
||
60 | * @param FormatterInterface $formatter Formatter instance. |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function addFormatter($key, FormatterInterface $formatter) |
||
70 | |||
71 | /** |
||
72 | * @param array|\Traversable $formatters |
||
73 | * |
||
74 | * @return $this |
||
75 | */ |
||
76 | public function addFormatters($formatters) |
||
84 | |||
85 | /** |
||
86 | * @param mixed $key |
||
87 | * |
||
88 | * @return FormatterInterface |
||
89 | */ |
||
90 | 3 | public function getFormatter($key) |
|
100 | |||
101 | /** |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getEscapeCharacter() |
||
108 | |||
109 | /** |
||
110 | * @param string $escapeCharacter |
||
111 | * |
||
112 | * @return AbstractCsv |
||
113 | */ |
||
114 | public function setEscapeCharacter($escapeCharacter) |
||
120 | |||
121 | /** |
||
122 | * Reads the next line in the CSV file |
||
123 | * and returns a Row object from it. |
||
124 | * |
||
125 | * @return Row |
||
126 | */ |
||
127 | protected function getNextRow() |
||
145 | |||
146 | /** |
||
147 | * @inheritDoc |
||
148 | */ |
||
149 | public function current() |
||
153 | |||
154 | /** |
||
155 | * @inheritDoc |
||
156 | */ |
||
157 | public function next() |
||
161 | |||
162 | /** |
||
163 | * @inheritDoc |
||
164 | */ |
||
165 | public function key() |
||
169 | |||
170 | /** |
||
171 | * @inheritDoc |
||
172 | */ |
||
173 | public function valid() |
||
179 | |||
180 | /** |
||
181 | * @inheritDoc |
||
182 | */ |
||
183 | public function rewind() |
||
197 | |||
198 | /** |
||
199 | * @inheritDoc |
||
200 | */ |
||
201 | public function count() |
||
205 | } |
||
206 |