1 | <?php |
||
13 | class Reader extends AbstractCsv implements \Iterator, \Countable |
||
14 | { |
||
15 | public static $defaultFormatter = StringFormatter::class; |
||
16 | |||
17 | protected $openMode = '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 | 1 | public function createDocument() |
|
47 | |||
48 | /** |
||
49 | * @return Row |
||
50 | */ |
||
51 | public function getHeaders() |
||
55 | |||
56 | 3 | public function getHeader($key) |
|
64 | |||
65 | /** |
||
66 | * @param mixed $key |
||
67 | * @param FormatterInterface $formatter Formatter instance. |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function addFormatter($key, FormatterInterface $formatter) |
||
77 | |||
78 | /** |
||
79 | * @param array|\Traversable $formatters |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function addFormatters($formatters) |
||
91 | |||
92 | /** |
||
93 | * @param mixed $key |
||
94 | * |
||
95 | * @return FormatterInterface |
||
96 | */ |
||
97 | 3 | public function getFormatter($key) |
|
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getEscapeCharacter() |
||
115 | |||
116 | /** |
||
117 | * @param string $escapeCharacter |
||
118 | * |
||
119 | * @return AbstractCsv |
||
120 | */ |
||
121 | public function setEscapeCharacter($escapeCharacter) |
||
127 | |||
128 | /** |
||
129 | * Reads the next line in the CSV file |
||
130 | * and returns a Row object from it. |
||
131 | * |
||
132 | * @return Row |
||
133 | */ |
||
134 | protected function getNextRow() |
||
146 | |||
147 | /** |
||
148 | * @inheritDoc |
||
149 | */ |
||
150 | public function current() |
||
154 | |||
155 | /** |
||
156 | * @inheritDoc |
||
157 | */ |
||
158 | public function next() |
||
164 | |||
165 | /** |
||
166 | * @inheritDoc |
||
167 | */ |
||
168 | public function key() |
||
172 | |||
173 | /** |
||
174 | * @inheritDoc |
||
175 | */ |
||
176 | public function valid() |
||
182 | |||
183 | /** |
||
184 | * @inheritDoc |
||
185 | */ |
||
186 | public function rewind() |
||
196 | |||
197 | /** |
||
198 | * @inheritDoc |
||
199 | */ |
||
200 | public function count() |
||
204 | } |
||
205 |