Passed
Push — master ( a1e4cd...aeaa07 )
by Thiago
32s
created

Pdf::convert()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
namespace MrPrompt\BoletoCaixaEconomicaFederal\Converter;
3
4
use Knp\Snappy\Pdf as Converter;
5
6
/**
7
 * PDF Converter
8
 *
9
 * @author Thiago Paes <[email protected]>
10
 */
11
class Pdf
12
{
13
    /**
14
     * Wkhtmltopdf executable
15
     *
16
     * @const string
17
     */
18
    const PDF_TOOL = '/usr/local/bin/wkhtmltopdf';
19
20
    /**
21
     * @param string $content
22
     * @param string $outputFile
23
     */
24
    public static function convert($content, $outputFile)
25
    {
26
        if (is_file(static::PDF_TOOL) && is_executable(static::PDF_TOOL)) {
27
            $snappy = new Converter(static::PDF_TOOL);
28
            $snappy->generateFromHtml($content, str_replace('.HTML', '.PDF', $outputFile), [], true);
29
        }
30
    }
31
}