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