Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3.009 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 4 | private function fileDownload($content, $filename) |
|
|
|||
16 | { |
||
17 | 4 | $contentDisposition = sprintf("attachment; filename*=utf-8''%s", rawurlencode($filename)); |
|
18 | |||
19 | 4 | $response = new Response(); |
|
20 | |||
21 | 4 | if (is_string($content)) { |
|
22 | 3 | $body = $response->getBody(); |
|
23 | 3 | $body->write($content); |
|
24 | } elseif ($content instanceof StreamInterface) { |
||
25 | 1 | $body = $content; |
|
26 | } |
||
27 | |||
28 | return $response |
||
29 | 4 | ->withBody($body) |
|
30 | 4 | ->withHeader('Content-Disposition', $contentDisposition); |
|
31 | } |
||
32 | } |