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 | private $initial; |
||
46 | |||
47 | /** |
||
48 | * @param CsvFormatInterface $csvFormat |
||
49 | */ |
||
50 | 15 | public function __construct(CsvFormatInterface $csvFormat) |
|
84 | |||
85 | /** |
||
86 | * @param array $data |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | 11 | public function format(array $data) |
|
104 | |||
105 | /** |
||
106 | * @param string $string |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | 11 | protected function escape($string) |
|
114 | |||
115 | /** |
||
116 | * @param string $string |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | 12 | private function encode($string) |
|
124 | |||
125 | /** |
||
126 | * Return an initial block if required |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | 5 | public function getInitialBlock() |
|
134 | |||
135 | /** |
||
136 | * Get a separator between each row |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 4 | public function getRowSeparator() |
|
144 | |||
145 | /** |
||
146 | * Return a closing block if required |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | 5 | public function getClosingBlock() |
|
154 | } |
||
155 |