Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 | }); |
||
50 |
If you suppress an error, we recommend checking for the error condition explicitly: