1 | <?php |
||
13 | class ReaderOptions extends \Box\Spout\Reader\Common\ReaderOptions |
||
14 | { |
||
15 | /** @var string Defines the character used to delimit fields (one character only) */ |
||
16 | protected $fieldDelimiter = ','; |
||
17 | |||
18 | /** @var string Defines the character used to enclose fields (one character only) */ |
||
19 | protected $fieldEnclosure = '"'; |
||
20 | |||
21 | /** @var string Encoding of the CSV file to be read */ |
||
22 | protected $encoding = EncodingHelper::ENCODING_UTF8; |
||
23 | |||
24 | /** @var string Defines the End of line */ |
||
25 | protected $endOfLineCharacter = "\n"; |
||
26 | |||
27 | /** |
||
28 | * Alignment with other functions like fgets() is discussed here: https://bugs.php.net/bug.php?id=48421 |
||
29 | * @var int Number of bytes to read |
||
30 | */ |
||
31 | protected $maxReadBytesPerLine = 32768; |
||
32 | |||
33 | /** |
||
34 | * @return string |
||
35 | */ |
||
36 | 81 | public function getFieldDelimiter() |
|
40 | |||
41 | /** |
||
42 | * Sets the field delimiter for the CSV. |
||
43 | * Needs to be called before opening the reader. |
||
44 | * |
||
45 | * @param string $fieldDelimiter Character that delimits fields |
||
46 | * @return ReaderOptions |
||
47 | */ |
||
48 | 63 | public function setFieldDelimiter($fieldDelimiter) |
|
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | 81 | public function getFieldEnclosure() |
|
61 | |||
62 | /** |
||
63 | * Sets the field enclosure for the CSV. |
||
64 | * Needs to be called before opening the reader. |
||
65 | * |
||
66 | * @param string $fieldEnclosure Character that enclose fields |
||
67 | * @return ReaderOptions |
||
68 | */ |
||
69 | 63 | public function setFieldEnclosure($fieldEnclosure) |
|
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | 81 | public function getEncoding() |
|
82 | |||
83 | /** |
||
84 | * Sets the encoding of the CSV file to be read. |
||
85 | * Needs to be called before opening the reader. |
||
86 | * |
||
87 | * @param string $encoding Encoding of the CSV file to be read |
||
88 | * @return ReaderOptions |
||
89 | */ |
||
90 | 75 | public function setEncoding($encoding) |
|
95 | |||
96 | /** |
||
97 | * @return string EOL for the CSV |
||
98 | */ |
||
99 | 81 | public function getEndOfLineCharacter() |
|
103 | |||
104 | /** |
||
105 | * Sets the EOL for the CSV. |
||
106 | * Needs to be called before opening the reader. |
||
107 | * |
||
108 | * @param string $endOfLineCharacter used to properly get lines from the CSV file. |
||
109 | * @return ReaderOptions |
||
110 | */ |
||
111 | 63 | public function setEndOfLineCharacter($endOfLineCharacter) |
|
116 | |||
117 | /** |
||
118 | * Sets maximum bytes to read in line |
||
119 | * |
||
120 | * @param int $maxReadBytesPerLine |
||
121 | * @return ReaderOptions |
||
122 | */ |
||
123 | 63 | public function setMaxReadBytesPerLine($maxReadBytesPerLine) |
|
128 | |||
129 | /** |
||
130 | * Gets maximum bytes to read in line |
||
131 | * |
||
132 | * @return int |
||
133 | */ |
||
134 | 81 | public function getMaxReadBytesPerLine() |
|
138 | } |
||
139 |