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

PDFResponse   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 6
c 1
b 0
f 0
dl 0
loc 10
rs 10

1 Method

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