| Total Complexity | 5 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class CsvConverter extends AbstractConverter |
||
| 9 | { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | private $glue = '","'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $body = ''; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @return string data converted into CSV |
||
| 23 | */ |
||
| 24 | public function convert() |
||
| 25 | { |
||
| 26 | array_walk($this->countries, [$this, 'processCountry']); |
||
| 27 | $headers = '"' . implode($this->glue, array_keys($this->countries[0])) . '"'; |
||
| 28 | return $headers . "\n" . $this->body; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @return string |
||
| 33 | */ |
||
| 34 | public function getGlue() |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $glue |
||
| 41 | */ |
||
| 42 | public function setGlue($glue) |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Processes a country. |
||
| 49 | * @param $array |
||
| 50 | */ |
||
| 51 | private function processCountry(&$array) |
||
| 57 | } |
||
| 58 | } |