1 | <?php |
||
14 | class Reader extends AbstractReader |
||
15 | { |
||
16 | /** @var resource Pointer to the file to be written */ |
||
17 | protected $filePointer; |
||
18 | |||
19 | /** @var SheetIterator To iterator over the CSV unique "sheet" */ |
||
20 | protected $sheetIterator; |
||
21 | |||
22 | /** @var string Original value for the "auto_detect_line_endings" INI value */ |
||
23 | protected $originalAutoDetectLineEndings; |
||
24 | |||
25 | /** |
||
26 | * Returns the reader's current options |
||
27 | * |
||
28 | * @return ReaderOptions |
||
29 | */ |
||
30 | 78 | protected function getOptions() |
|
31 | { |
||
32 | 78 | if (!isset($this->options)) { |
|
33 | 78 | $this->options = new ReaderOptions(); |
|
34 | 78 | } |
|
35 | 78 | return $this->options; |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Sets the field delimiter for the CSV. |
||
40 | * Needs to be called before opening the reader. |
||
41 | * |
||
42 | * @param string $fieldDelimiter Character that delimits fields |
||
43 | * @return Reader |
||
44 | */ |
||
45 | 60 | public function setFieldDelimiter($fieldDelimiter) |
|
50 | |||
51 | /** |
||
52 | * Sets the field enclosure for the CSV. |
||
53 | * Needs to be called before opening the reader. |
||
54 | * |
||
55 | * @param string $fieldEnclosure Character that enclose fields |
||
56 | * @return Reader |
||
57 | */ |
||
58 | 60 | public function setFieldEnclosure($fieldEnclosure) |
|
63 | |||
64 | /** |
||
65 | * Sets the encoding of the CSV file to be read. |
||
66 | * Needs to be called before opening the reader. |
||
67 | * |
||
68 | * @param string $encoding Encoding of the CSV file to be read |
||
69 | * @return Reader |
||
70 | */ |
||
71 | 72 | public function setEncoding($encoding) |
|
76 | |||
77 | /** |
||
78 | * Sets the EOL for the CSV. |
||
79 | * Needs to be called before opening the reader. |
||
80 | * |
||
81 | * @param string $endOfLineCharacter used to properly get lines from the CSV file. |
||
82 | * @return Reader |
||
83 | */ |
||
84 | 60 | public function setEndOfLineCharacter($endOfLineCharacter) |
|
89 | |||
90 | public function setMaxReadBytesPerLine($maxReadBytesPerLine) |
||
95 | 6 | ||
96 | /** |
||
97 | 6 | * Returns whether stream wrappers are supported |
|
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | protected function doesSupportStreamWrapper() |
||
105 | |||
106 | /** |
||
107 | * Opens the file at the given path to make it ready to be read. |
||
108 | 81 | * If setEncoding() was not called, it assumes that the file is encoded in UTF-8. |
|
109 | * |
||
110 | 81 | * @param string $filePath Path of the CSV file to be read |
|
111 | 81 | * @return void |
|
112 | * @throws \Box\Spout\Common\Exception\IOException |
||
113 | 81 | */ |
|
114 | 81 | protected function openReader($filePath) |
|
130 | 78 | ||
131 | /** |
||
132 | 78 | * Returns an iterator to iterate over sheets. |
|
133 | * |
||
134 | * @return SheetIterator To iterate over sheets |
||
135 | */ |
||
136 | protected function getConcreteSheetIterator() |
||
140 | |||
141 | 78 | ||
142 | /** |
||
143 | 78 | * Closes the reader. To be used after reading the file. |
|
144 | 78 | * |
|
145 | 78 | * @return void |
|
146 | */ |
||
147 | 78 | protected function closeReader() |
|
155 | } |
||
156 |