Passed
Push — master ( cf0bfa...d7e9ff )
by Jan
05:15
created

PDFResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/*
3
 * Copyright (C)  2020-2022  Jan Böhmer
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published
7
 * by the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
namespace App\Helpers;
20
21
use Symfony\Component\HttpFoundation\Response;
22
23
class PDFResponse extends Response
24
{
25
    public function __construct(string $pdf_data)
26
    {
27
        parent::__construct($pdf_data);
28
29
        $this->headers->set('Content-type', 'application/pdf');
30
        $this->headers->set('Content-length', strlen($pdf_data));
31
        $this->headers->set('Cache-Control', 'private');
32
        $this->headers->set('Content-Disposition', 'inline');
33
    }
34
}