1 | <?php |
||
13 | class Reader extends AbstractCsv implements \Iterator |
||
14 | { |
||
15 | /** @var string */ |
||
16 | protected $defaultFormatter = NullFormatter::class; |
||
17 | /** @var string */ |
||
18 | protected $openMode = 'r'; |
||
19 | /** @var FormatterInterface[] */ |
||
20 | protected $formatters = []; |
||
21 | /** @var Row */ |
||
22 | protected $headers; |
||
23 | /** @var Row */ |
||
24 | protected $row; |
||
25 | |||
26 | /** |
||
27 | * @param string $file |
||
28 | * |
||
29 | * @return Reader |
||
30 | */ |
||
31 | public static function read($file) |
||
37 | |||
38 | /** |
||
39 | * @return Row |
||
40 | */ |
||
41 | public function getHeaders() |
||
42 | { |
||
43 | return $this->headers; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param $key |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 3 | public function getHeader($key) |
|
59 | |||
60 | /** |
||
61 | * @param mixed $key |
||
62 | * @param FormatterInterface $formatter Formatter instance. |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function addFormatter($key, FormatterInterface $formatter) |
||
72 | |||
73 | /** |
||
74 | * @param array|\Traversable $formatters |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function addFormatters($formatters) |
||
86 | |||
87 | /** |
||
88 | * @param mixed $key |
||
89 | * |
||
90 | * @return FormatterInterface |
||
91 | */ |
||
92 | 3 | public function getFormatter($key) |
|
102 | |||
103 | /** |
||
104 | * Reads the next line in the CSV file |
||
105 | * and returns a Row object from it. |
||
106 | * |
||
107 | * @return Row|null |
||
108 | */ |
||
109 | protected function getCurrentRow() |
||
121 | |||
122 | /** |
||
123 | * @inheritDoc |
||
124 | */ |
||
125 | public function current() |
||
129 | |||
130 | /** |
||
131 | * @inheritDoc |
||
132 | */ |
||
133 | public function next() |
||
137 | |||
138 | /** |
||
139 | * @inheritDoc |
||
140 | */ |
||
141 | public function key() |
||
145 | |||
146 | /** |
||
147 | * @inheritDoc |
||
148 | */ |
||
149 | public function valid() |
||
155 | |||
156 | /** |
||
157 | * @inheritDoc |
||
158 | */ |
||
159 | public function rewind() |
||
167 | |||
168 | /** |
||
169 | * @param string $defaultFormatter |
||
170 | * |
||
171 | * @return Reader |
||
172 | */ |
||
173 | public function setDefaultFormatter($defaultFormatter) |
||
179 | |||
180 | /** |
||
181 | * @return string |
||
182 | */ |
||
183 | 3 | public function getDefaultFormatter() |
|
187 | } |
||
188 |