Converter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
/** @noinspection PhpInternalEntityUsedInspection */
4
5
declare(strict_types=1);
6
7
namespace PhpCfdi\CfdiToPdf;
8
9
use CfdiUtils\Internals\TemporaryFile;
10
use PhpCfdi\CfdiToPdf\Builders\BuilderInterface;
11
12
class Converter
13
{
14
    /** @var BuilderInterface */
15
    private $builder;
16
17 5
    public function __construct(BuilderInterface $builder)
18
    {
19 5
        $this->builder = $builder;
20
    }
21
22
    /**
23
     * @param CfdiData $cfdiData
24
     * @param string $destination
25
     * @return void
26
     */
27 4
    public function createPdfAs(CfdiData $cfdiData, string $destination): void
28
    {
29 4
        $this->builder->build($cfdiData, $destination);
30
    }
31
32 1
    public function createPdf(CfdiData $cfdiData): string
33
    {
34 1
        $temporary = TemporaryFile::create();
35 1
        $filename = $temporary->getPath();
36 1
        $this->builder->build($cfdiData, $filename);
37 1
        return $filename;
38
    }
39
}
40