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 ( fef613...8eeb44 )
by Pascal
01:36 queued 12s
created

Ghostscript::tempFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ProtoneMedia\LaravelMixins\Pdf;
4
5
use Symfony\Component\Process\Process;
6
7
class Ghostscript implements CanRegeneratePDF
8
{
9
    /**
10
     * Ghostscript binary path.
11
     */
12
    private string $bin;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
13
14
    public function __construct(string $bin = 'ghostscript')
15
    {
16
        $this->bin = $bin;
17
    }
18
19
    /**
20
     * Generates a temporary filename for a PDF file.
21
     *
22
     * @return string
23
     */
24
    private static function tempFile(): string
25
    {
26
        return tempnam(sys_get_temp_dir(), 'ghostscript') . '.pdf';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function regeneratePdf(string $pdfContents): string
33
    {
34
        file_put_contents($input = static::tempFile(), $pdfContents);
35
36
        (new Process([
37
            $this->bin,
38
            '-sDEVICE=pdfwrite',
39
            '-dPDFSETTINGS=/prepress',
40
            '-sOutputFile=' . $destination = static::tempFile(),
41
            $input,
42
        ]))->run();
43
44
        return tap(@file_get_contents($destination), function () use ($input, $destination) {
45
            @unlink($input);
46
            @unlink($destination);
47
        });
48
    }
49
}
50