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() |
||
139 | |||
140 | /** |
||
141 | * @inheritDoc |
||
142 | */ |
||
143 | public function current() |
||
147 | |||
148 | /** |
||
149 | * @inheritDoc |
||
150 | */ |
||
151 | public function next() |
||
155 | |||
156 | /** |
||
157 | * @inheritDoc |
||
158 | */ |
||
159 | public function key() |
||
163 | |||
164 | /** |
||
165 | * @inheritDoc |
||
166 | */ |
||
167 | public function valid() |
||
173 | |||
174 | /** |
||
175 | * @inheritDoc |
||
176 | */ |
||
177 | public function rewind() |
||
191 | |||
192 | /** |
||
193 | * @inheritDoc |
||
194 | */ |
||
195 | public function count() |
||
199 | } |
||
200 |