| Conditions | 3 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.3332 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 3 | private function fileDownload($content, $filename) |
|
|
|
|||
| 18 | { |
||
| 19 | 3 | if ($content instanceof StreamInterface) { |
|
| 20 | $response = new StreamedResponse(); |
||
| 21 | |||
| 22 | $response->setCallback(function () use ($content) { |
||
| 23 | $content->rewind(); |
||
| 24 | |||
| 25 | while (! $content->eof()) { |
||
| 26 | echo $content->read(8192); |
||
| 27 | } |
||
| 28 | }); |
||
| 29 | } else { |
||
| 30 | 3 | $response = new Response($content); |
|
| 31 | } |
||
| 32 | |||
| 33 | 3 | $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename); |
|
| 34 | 3 | $response->headers->set('Content-Disposition', $disposition); |
|
| 35 | |||
| 36 | 3 | return $response; |
|
| 37 | } |
||
| 38 | } |
||
| 39 |