GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 849081...41cde1 )
by Christian
07:11
created

DompdfWrapper::getStreamResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\DompdfBundle\Wrapper;
13
14
use Core23\DompdfBundle\Factory\DompdfFactoryInterface;
15
use Symfony\Component\HttpFoundation\StreamedResponse;
16
17
final class DompdfWrapper implements DompdfWrapperInterface
18
{
19
    /**
20
     * @var DompdfFactoryInterface
21
     */
22
    private $dompdfFactory;
23
24
    /**
25
     * @param DompdfFactoryInterface $dompdfFactory
26
     */
27
    public function __construct(DompdfFactoryInterface $dompdfFactory)
28
    {
29
        $this->dompdfFactory = $dompdfFactory;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function streamHtml(string $html, string $filename, array $options = []): void
36
    {
37
        $pdf = $this->dompdfFactory->create($options);
38
        $pdf->loadHtml($html);
39
        $pdf->render();
40
        $pdf->stream($filename, $options);
41
    }
42
43
    /**
44
     * @param string $html
45
     * @param string $filename
46
     * @param array  $options
47
     *
48
     * @return StreamedResponse
49
     */
50
    public function getStreamResponse(string $html, string $filename, array $options = []): StreamedResponse
51
    {
52
        $response = new StreamedResponse();
53
        $response->setCallback(function () use ($html, $filename, $options): void {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after closing parenthesis; found 0
Loading history...
54
            $this->streamHtml($html, $filename, $options);
55
        });
56
57
        return $response;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getPdf(string $html, array $options = []): string
64
    {
65
        $pdf = $this->dompdfFactory->create($options);
66
        $pdf->loadHtml($html);
67
        $pdf->render();
68
69
        return $pdf->output();
70
    }
71
}
72