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 | 78 | */ |
|
31 | protected $maxReadBytesPerLine = 32768; |
||
32 | 78 | ||
33 | /** |
||
34 | * @return string |
||
35 | */ |
||
36 | public function getFieldDelimiter() |
||
40 | |||
41 | /** |
||
42 | 60 | * Sets the field delimiter for the CSV. |
|
43 | * Needs to be called before opening the reader. |
||
44 | 60 | * |
|
45 | 60 | * @param string $fieldDelimiter Character that delimits fields |
|
46 | * @return ReaderOptions |
||
47 | */ |
||
48 | public function setFieldDelimiter($fieldDelimiter) |
||
53 | 78 | ||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getFieldEnclosure() |
||
61 | |||
62 | /** |
||
63 | 60 | * Sets the field enclosure for the CSV. |
|
64 | * Needs to be called before opening the reader. |
||
65 | 60 | * |
|
66 | 60 | * @param string $fieldEnclosure Character that enclose fields |
|
67 | * @return ReaderOptions |
||
68 | */ |
||
69 | public function setFieldEnclosure($fieldEnclosure) |
||
74 | 78 | ||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | public function getEncoding() |
||
82 | |||
83 | /** |
||
84 | 72 | * Sets the encoding of the CSV file to be read. |
|
85 | * Needs to be called before opening the reader. |
||
86 | 72 | * |
|
87 | 72 | * @param string $encoding Encoding of the CSV file to be read |
|
88 | * @return ReaderOptions |
||
89 | */ |
||
90 | public function setEncoding($encoding) |
||
95 | 78 | ||
96 | /** |
||
97 | * @return string EOL for the CSV |
||
98 | */ |
||
99 | public function getEndOfLineCharacter() |
||
103 | |||
104 | /** |
||
105 | 60 | * Sets the EOL for the CSV. |
|
106 | * Needs to be called before opening the reader. |
||
107 | 60 | * |
|
108 | 60 | * @param string $endOfLineCharacter used to properly get lines from the CSV file. |
|
109 | * @return ReaderOptions |
||
110 | */ |
||
111 | public function setEndOfLineCharacter($endOfLineCharacter) |
||
116 | |||
117 | /** |
||
118 | * Sets maximum bytes to read in line |
||
119 | * |
||
120 | * @param int $maxReadBytesPerLine |
||
121 | * @return ReaderOptions |
||
122 | */ |
||
123 | public function setMaxReadBytesPerLine($maxReadBytesPerLine) |
||
128 | |||
129 | /** |
||
130 | * Gets maximum bytes to read in line |
||
131 | * |
||
132 | * @return int |
||
133 | */ |
||
134 | public function getMaxReadBytesPerLine() |
||
138 | } |
||
139 |