Completed
Push — master ( a35e81...521884 )
by Carlos C
03:49 queued 10s
created

CfdiData::comprobante()   A

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 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\CfdiToPdf;
6
7
use CfdiUtils\Nodes\NodeInterface;
8
use RuntimeException;
9
10
class CfdiData
11
{
12
    /** @var NodeInterface */
13
    private $comprobante;
14
15
    /** @var NodeInterface */
16
    private $emisor;
17
18
    /** @var NodeInterface */
19
    private $receptor;
20
21
    /** @var NodeInterface */
22
    private $timbreFiscalDigital;
23
24
    /** @var string */
25
    private $qrUrl;
26
27
    /** @var string */
28
    private $tfdSourceString;
29
30 5
    public function __construct(NodeInterface $comprobante, string $qrUrl, string $tfdSourceString)
31
    {
32 5
        $emisor = $comprobante->searchNode('cfdi:Emisor');
33 5
        if (null === $emisor) {
34 1
            throw new RuntimeException('El CFDI no contiene nodo emisor');
35
        }
36 4
        $receptor = $comprobante->searchNode('cfdi:Receptor');
37 4
        if (null === $receptor) {
38 1
            throw new RuntimeException('El CFDI no contiene nodo receptor');
39
        }
40 3
        $timbreFiscalDigital = $comprobante->searchNode('cfdi:Complemento', 'tfd:TimbreFiscalDigital');
41 3
        if (null === $timbreFiscalDigital) {
42 1
            throw new RuntimeException('El CFDI no contiene complemento de timbre fiscal digital');
43
        }
44
45 2
        $this->comprobante = $comprobante;
46 2
        $this->emisor = $emisor;
47 2
        $this->receptor = $receptor;
48 2
        $this->timbreFiscalDigital = $timbreFiscalDigital;
49 2
        $this->qrUrl = $qrUrl;
50 2
        $this->tfdSourceString = $tfdSourceString;
51 2
    }
52
53 2
    public function comprobante(): NodeInterface
54
    {
55 2
        return $this->comprobante;
56
    }
57
58 2
    public function emisor(): NodeInterface
59
    {
60 2
        return $this->emisor;
61
    }
62
63 2
    public function receptor(): NodeInterface
64
    {
65 2
        return $this->receptor;
66
    }
67
68 2
    public function timbreFiscalDigital(): NodeInterface
69
    {
70 2
        return $this->timbreFiscalDigital;
71
    }
72
73 2
    public function qrUrl(): string
74
    {
75 2
        return $this->qrUrl;
76
    }
77
78 2
    public function tfdSourceString(): string
79
    {
80 2
        return $this->tfdSourceString;
81
    }
82
}
83