1 | <?php |
||
22 | class CsvFormatter implements FormatterInterface |
||
23 | { |
||
24 | use RowProcessor; |
||
25 | use InvokeFormatter; |
||
26 | |||
27 | /** |
||
28 | * @var CsvFormatInterface |
||
29 | */ |
||
30 | private $csvFormat; |
||
31 | |||
32 | /** |
||
33 | * @var string[] |
||
34 | */ |
||
35 | private $escapeChars; |
||
36 | |||
37 | /** |
||
38 | * @var string[] |
||
39 | */ |
||
40 | private $replaceChars; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | 14 | private $initial; |
|
46 | |||
47 | 14 | /** |
|
48 | * @param CsvFormatInterface $csvFormat |
||
49 | 14 | */ |
|
50 | 12 | public function __construct(CsvFormatInterface $csvFormat) |
|
84 | |||
85 | 11 | /** |
|
86 | * @param array $data |
||
87 | 11 | * |
|
88 | 11 | * @return string |
|
89 | 4 | */ |
|
90 | 4 | public function format(array $data) |
|
104 | |||
105 | 11 | /** |
|
106 | * @param string $string |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | protected function escape($string) |
||
114 | |||
115 | 4 | /** |
|
116 | * @param string $string |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | private function encode($string) |
||
124 | |||
125 | 4 | /** |
|
126 | * Return an initial block if required |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getInitialBlock() |
||
134 | |||
135 | 4 | /** |
|
136 | * Get a separator between each row |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getRowSeparator() |
||
144 | |||
145 | /** |
||
146 | * Return a closing block if required |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | public function getClosingBlock() |
||
154 | } |
||
155 |