Total Complexity | 3 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class Ghostscript implements CanRegeneratePDF |
||
8 | { |
||
9 | /** |
||
10 | * Ghostscript binary path. |
||
11 | */ |
||
12 | private string $bin; |
||
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 |
||
47 | }); |
||
48 | } |
||
49 | } |
||
50 |
If you suppress an error, we recommend checking for the error condition explicitly: