1 | <?php |
||
15 | class Reader extends AbstractReader |
||
16 | { |
||
17 | /** @var resource Pointer to the file to be written */ |
||
18 | protected $filePointer; |
||
19 | |||
20 | /** @var SheetIterator To iterator over the CSV unique "sheet" */ |
||
21 | protected $sheetIterator; |
||
22 | |||
23 | /** @var string Defines the character used to delimit fields (one character only) */ |
||
24 | protected $fieldDelimiter = ','; |
||
25 | |||
26 | /** @var string Defines the character used to enclose fields (one character only) */ |
||
27 | protected $fieldEnclosure = '"'; |
||
28 | |||
29 | /** @var string Encoding of the CSV file to be read */ |
||
30 | protected $encoding = EncodingHelper::ENCODING_UTF8; |
||
31 | |||
32 | /** @var string Defines the End of line */ |
||
33 | protected $endOfLineCharacter = "\n"; |
||
34 | |||
35 | /** @var string */ |
||
36 | protected $autoDetectLineEndings; |
||
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 | 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 | 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 | 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 | public function setEndOfLineCharacter($endOfLineCharacter) |
||
89 | |||
90 | /** |
||
91 | * Returns whether stream wrappers are supported |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | protected function doesSupportStreamWrapper() |
||
99 | |||
100 | /** |
||
101 | * Opens the file at the given path to make it ready to be read. |
||
102 | * If setEncoding() was not called, it assumes that the file is encoded in UTF-8. |
||
103 | * |
||
104 | * @param string $filePath Path of the CSV file to be read |
||
105 | * @return void |
||
106 | * @throws \Box\Spout\Common\Exception\IOException |
||
107 | */ |
||
108 | protected function openReader($filePath) |
||
127 | |||
128 | /** |
||
129 | * Returns an iterator to iterate over sheets. |
||
130 | * |
||
131 | * @return SheetIterator To iterate over sheets |
||
132 | */ |
||
133 | public function getConcreteSheetIterator() |
||
137 | |||
138 | |||
139 | /** |
||
140 | * Closes the reader. To be used after reading the file. |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | protected function closeReader() |
||
152 | } |
||
153 |