Converter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A createPdf() 0 6 1
A createPdfAs() 0 3 1
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