Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
42 | 10 | public function write(array $fields): int |
|
43 | 10 | { |
|
44 | 1 | $options = $this->getCsvControl(); |
|
45 | $delimiter = $options[0]; |
||
46 | $enclosure = $options[1]; |
||
47 | if (! empty($enclosure)) { |
||
48 | 9 | return $this->fputcsv($fields, $delimiter, $enclosure); |
|
49 | 9 | } |
|
50 | |||
51 | 9 | $fields = array_map(static function ($field) use ($delimiter) { |
|
52 | return str_replace([$delimiter, PHP_EOL], ['', ''], (string) $field); |
||
53 | }, $fields); |
||
54 | |||
55 | return $this->fwrite(implode($delimiter, $fields) . PHP_EOL); |
||
56 | } |
||
58 |