Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
9 | public function __construct( |
||
10 | string $filePath, |
||
11 | string $outputFilename, |
||
12 | string $contentType = 'application/octet-stream' |
||
13 | ) { |
||
14 | if (!\is_readable($filePath)) { |
||
15 | throw new \WebServCo\Framework\Exceptions\NotFoundException('File not found.'); |
||
16 | } |
||
17 | |||
18 | parent::__construct( |
||
19 | '', // content |
||
20 | 200, // statusCode |
||
21 | [ |
||
22 | 'Content-Disposition' => [\sprintf('attachment; filename="%s"', $outputFilename)], |
||
23 | 'Content-Type' => [$contentType], |
||
24 | 'X-Sendfile' => [$filePath], |
||
25 | ], // headers |
||
29 |