Completed
Pull Request — version2 (#28)
by David
03:15
created

TimbreFiscalDigitalVersion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 15 2
1
<?php
2
namespace CfdiUtils\Validate\Cfdi33\Standard;
3
4
use CfdiUtils\Nodes\NodeInterface;
5
use CfdiUtils\Validate\Asserts;
6
use CfdiUtils\Validate\Cfdi33\Abstracts\AbstractDiscoverableVersion33;
7
use CfdiUtils\Validate\Status;
8
9
/**
10
 * TimbreFiscalDigitalVersion
11
 *
12
 * Valida que:
13
 * - TFDVERSION01: Si existe el complemento timbre fiscal digital, entonces su versión debe ser 1.1
14
 */
15
class TimbreFiscalDigitalVersion extends AbstractDiscoverableVersion33
16
{
17 12
    public function validate(NodeInterface $comprobante, Asserts $asserts)
18
    {
19 12
        $asserts->put(
20 12
            'TFDVERSION01',
21 12
            'Si existe el complemento timbre fiscal digital, entonces su versión debe ser 1.1'
22
        );
23
24 12
        $tfdVersion = $comprobante->searchNode('cfdi:Complemento', 'tfd:TimbreFiscalDigital');
25 12
        if (null !== $tfdVersion) {
26 8
            $asserts->putStatus(
27 8
                'TFDVERSION01',
28 8
                Status::when('1.1' === $tfdVersion['Version'])
29
            );
30
        }
31 12
    }
32
}
33