| Conditions | 5 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 1 | protected function processFile($filename, $data) |
|
| 30 | { |
||
| 31 | 1 | $filepath = $this->getFolderToLoad() . DIRECTORY_SEPARATOR . $filename . '.' . $this->fileExtension; |
|
| 32 | 1 | if (!is_dir(dirname($filepath))) { |
|
| 33 | 1 | mkdir(dirname($filepath), 0700, true); |
|
| 34 | } |
||
| 35 | 1 | $fp = fopen($filepath, 'w'); |
|
| 36 | |||
| 37 | //write headers |
||
| 38 | 1 | fputcsv($fp, array_keys($data[0]), ',', '"'); |
|
| 39 | 1 | foreach ($data as $row) { |
|
| 40 | 1 | $row = array_map(function ($e) { |
|
| 41 | 1 | if (is_array($e)) { |
|
| 42 | 1 | if (count($e) === 0) { |
|
| 43 | 1 | return '|'; |
|
| 44 | } |
||
| 45 | 1 | return implode('|', $e); |
|
| 46 | } |
||
| 47 | 1 | return $e; |
|
| 48 | 1 | }, $row); |
|
| 49 | 1 | fputcsv($fp, $row); |
|
| 50 | } |
||
| 51 | 1 | fclose($fp); |
|
| 52 | 1 | } |
|
| 54 |