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

XSendFileResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 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