1 | <?php |
||
5 | abstract class AbstractCsv |
||
6 | { |
||
7 | /** @var string */ |
||
8 | protected $fopenMode; |
||
9 | /** @var string */ |
||
10 | protected $file; |
||
11 | /** @var bool */ |
||
12 | protected $hasHeaders; |
||
13 | /** @var string */ |
||
14 | protected $delimiter; |
||
15 | /** @var string */ |
||
16 | protected $enclosure; |
||
17 | /** @var \SplFileObject */ |
||
18 | protected $document; |
||
19 | |||
20 | /** |
||
21 | * AbstractCsv constructor. |
||
22 | * |
||
23 | * @param string $file Path to CSV file. |
||
24 | * @param bool $hasHeaders Whether the CSV file contains headers. |
||
25 | * @param string $delimiter Cell delimiter. Default ',' (comma). |
||
26 | * @param string $enclosure Cell enclosure. Default '"' (double quote) |
||
27 | */ |
||
28 | 5 | public function __construct($file, $hasHeaders = true, $delimiter = ',', $enclosure = '"') |
|
35 | |||
36 | /** |
||
37 | * Reader destructor. |
||
38 | */ |
||
39 | 5 | public function __destruct() |
|
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | 2 | public function getFile() |
|
51 | |||
52 | /** |
||
53 | * @param string $file |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | 5 | public function setFile($file) |
|
63 | |||
64 | /** |
||
65 | * @param string $openMode |
||
66 | */ |
||
67 | 2 | public function createDocument($openMode = '') |
|
86 | |||
87 | /** |
||
88 | * |
||
89 | */ |
||
90 | 5 | public function closeDocument() |
|
94 | |||
95 | /** |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function hasHeaders() |
||
102 | |||
103 | /** |
||
104 | * @param bool $hasHeaders |
||
105 | * |
||
106 | * @return AbstractCsv |
||
107 | */ |
||
108 | 5 | public function setHasHeaders($hasHeaders) |
|
114 | |||
115 | /** |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getDelimiter() |
||
122 | |||
123 | /** |
||
124 | * @param string $delimiter |
||
125 | * |
||
126 | * @return AbstractCsv |
||
127 | */ |
||
128 | 5 | public function setDelimiter($delimiter) |
|
134 | |||
135 | /** |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getEnclosure() |
||
142 | |||
143 | /** |
||
144 | * @param string $enclosure |
||
145 | * |
||
146 | * @return AbstractCsv |
||
147 | */ |
||
148 | 5 | public function setEnclosure($enclosure) |
|
154 | |||
155 | /** |
||
156 | * @param \SplFileObject|null $document |
||
157 | * |
||
158 | * @return AbstractCsv |
||
159 | */ |
||
160 | 5 | public function setDocument($document) |
|
168 | |||
169 | /** |
||
170 | * @return \SplFileObject |
||
171 | */ |
||
172 | public function getDocument() |
||
176 | } |
||
177 |