| Conditions | 2 |
| Paths | 2 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 54 | 3 | private function buildFile(SheetInterface $sheet): FileInterface |
|
| 55 | { |
||
| 56 | 3 | $csv = fopen('php://temp', 'r+'); |
|
| 57 | |||
| 58 | 3 | if ($this->withHeader) { |
|
| 59 | 2 | fputcsv($csv, $sheet->columns()->keys()->toPrimitive(), $this->delimiter); |
|
| 60 | } |
||
| 61 | |||
| 62 | $sheet |
||
| 63 | 3 | ->rows() |
|
| 64 | 3 | ->reduce( |
|
| 65 | $csv, |
||
| 66 | 3 | function($carry, $identifier, RowInterface $row) { |
|
| 67 | 3 | fputcsv( |
|
| 68 | $carry, |
||
| 69 | 3 | $row->cells()->values()->toPrimitive(), |
|
| 70 | 3 | $this->delimiter |
|
| 71 | ); |
||
| 72 | |||
| 73 | 3 | return $carry; |
|
| 74 | 3 | } |
|
| 75 | ); |
||
| 76 | |||
| 77 | 3 | return new Csv($sheet->name(), new Stream($csv)); |
|
| 78 | } |
||
| 79 | } |
||
| 80 |