1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Libraries\ImportExport\Csv; |
4 | | | |
5 | | | class CsvBuilder |
6 | | | { |
7 | | | |
8 | | | private $csv; |
9 | | | private $insertLineBreaks; |
10 | | | |
11 | | | public function getCsv() |
12 | | | { |
13 | | | return $this->csv; |
14 | | | } |
15 | | | |
16 | | | public function getInsertLineBreaks() |
17 | | | { |
18 | | | return $this->insertLineBreaks; |
19 | | | } |
20 | | | |
21 | | | public function setInsertLineBreaks($insertLineBreaks) |
22 | | | { |
23 | | | $this->insertLineBreaks = $insertLineBreaks; |
24 | | | } |
25 | | | |
26 | | | function __construct() |
27 | | | { |
28 | | | $this->csv = ""; |
29 | | | $this->insertLineBreaks = false; |
30 | | | } |
31 | | | |
32 | | | public function appendValue($value) |
33 | | | { |
34 | | | if ($this->csv != "") |
35 | | | { |
36 | | | $this->csv .= ";"; |
37 | | | if ($this->insertLineBreaks) |
38 | | | $this->csv .= "\n"; |
39 | | | } |
40 | | | |
41 | | | $this->csv .= $value; |
42 | | | } |
43 | | | |
44 | | | public function appendEmptyValue() |
45 | | | { |
46 | | | $this->appendValue(""); |
47 | | | } |
48 | | | |
49 | | | public function appendEmptyValues($count) |
50 | | | { |
51 | | | for ($i = 0; $i < $count; $i ++) |
52 | | | { |
53 | | | $this->appendEmptyValue(); |
54 | | | } |
55 | | | } |
56 | | | |
57 | | | } |