1 | <?php |
||
13 | class Reader extends AbstractCsv implements \Iterator, \Countable |
||
14 | { |
||
15 | protected static $defaultFormatter = NullFormatter::class; |
||
16 | |||
17 | protected $openMode = 'r'; |
||
18 | /** @var FormatterInterface[] */ |
||
19 | protected $formatters = []; |
||
20 | /** @var Row */ |
||
21 | protected $headers; |
||
22 | /** @var Row */ |
||
23 | protected $row; |
||
24 | /** @var string */ |
||
25 | protected $escapeCharacter = "\0"; |
||
26 | |||
27 | /** |
||
28 | * @param $file |
||
29 | * |
||
30 | * @return Reader |
||
31 | */ |
||
32 | public static function read($file) |
||
38 | |||
39 | 1 | public function createDocument() |
|
45 | |||
46 | /** |
||
47 | * @return Row |
||
48 | */ |
||
49 | public function getHeaders() |
||
53 | |||
54 | 3 | public function getHeader($key) |
|
62 | |||
63 | /** |
||
64 | * @param mixed $key |
||
65 | * @param FormatterInterface $formatter Formatter instance. |
||
66 | * |
||
67 | * @return $this |
||
68 | */ |
||
69 | public function addFormatter($key, FormatterInterface $formatter) |
||
75 | |||
76 | /** |
||
77 | * @param array|\Traversable $formatters |
||
78 | * |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function addFormatters($formatters) |
||
89 | |||
90 | /** |
||
91 | * @param mixed $key |
||
92 | * |
||
93 | * @return FormatterInterface |
||
94 | */ |
||
95 | 3 | public function getFormatter($key) |
|
105 | |||
106 | /** |
||
107 | * @return string |
||
108 | */ |
||
109 | public function getEscapeCharacter() |
||
113 | |||
114 | /** |
||
115 | * @param string $escapeCharacter |
||
116 | * |
||
117 | * @return AbstractCsv |
||
118 | */ |
||
119 | public function setEscapeCharacter($escapeCharacter) |
||
125 | |||
126 | /** |
||
127 | * Reads the next line in the CSV file |
||
128 | * and returns a Row object from it. |
||
129 | * |
||
130 | * @return Row |
||
131 | */ |
||
132 | protected function getCurrentRow() |
||
144 | |||
145 | /** |
||
146 | * @inheritDoc |
||
147 | */ |
||
148 | public function current() |
||
152 | |||
153 | /** |
||
154 | * @inheritDoc |
||
155 | */ |
||
156 | public function next() |
||
160 | |||
161 | /** |
||
162 | * @inheritDoc |
||
163 | */ |
||
164 | public function key() |
||
168 | |||
169 | /** |
||
170 | * @inheritDoc |
||
171 | */ |
||
172 | public function valid() |
||
178 | |||
179 | /** |
||
180 | * @inheritDoc |
||
181 | */ |
||
182 | public function rewind() |
||
190 | |||
191 | /** |
||
192 | * @inheritDoc |
||
193 | */ |
||
194 | public function count() |
||
198 | |||
199 | public static function setDefaultFormatter($formatter) |
||
203 | } |
||
204 |