Passed
Push — master ( 9d098f...a79095 )
by Radu
01:17
created

XSendFileResponse::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
namespace WebServCo\Framework\Http;
3
4
class XSendFileResponse extends Response
5
{
6
    public function __construct($filePath, $outputFilename)
7
    {
8
        if (!is_readable($filePath)) {
9
            throw new \WebServCo\Framework\Exceptions\NotFoundException('File not found');
10
        }
11
12
        parent::__construct(
13
            null, // content
14
            200, // statusCode
15
            [
16
                'Content-Type' => 'application/octet-stream',
17
                'Content-Disposition' => sprintf(
18
                    'attachment; filename=%s',
19
                    $outputFilename
20
                ),
21
                'X-Sendfile' => $filePath,
22
            ] // headers
23
        );
24
    }
25
}
26