| Conditions | 3 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 14 | public function __construct($rows, $filename) |
|
| 28 | { |
||
| 29 | 14 | Assert::isIterable($rows, '$rows should be an array or an instance of \Traversable.'); |
|
| 30 | |||
| 31 | 13 | $this->rows = $rows; |
|
| 32 | |||
| 33 | 13 | parent::__construct(array($this, 'output'), 200, array( |
|
| 34 | 13 | 'Content-Type' => 'text/csv', |
|
| 35 | 13 | )); |
|
| 36 | |||
| 37 | try { |
||
| 38 | 13 | $disposition = $this->headers->makeDisposition('attachment', $filename, !preg_match('/^[\x20-\x7e]*$/', $filename) ? 'Download.csv' : ''); |
|
| 39 | 13 | } catch (\InvalidArgumentException $e) { |
|
| 40 | 1 | $disposition = $this->headers->makeDisposition('attachment', 'Download.csv'); |
|
| 41 | } |
||
| 42 | |||
| 43 | 13 | $this->headers->set('Content-Disposition', $disposition); |
|
| 44 | 13 | } |
|
| 45 | |||
| 60 |