Completed
Pull Request — master (#22)
by
unknown
09:47
created

Identify   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 96.55%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 38
ccs 28
cts 29
cp 0.9655
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B identificar() 0 35 2
1
<?php
2
3
namespace NFePHP\MDFe\Auxiliar;
4
5
/**
6
 * Classe para a identificação do documento eletrônico da NFe
7
 *
8
 * @category  NFePHP
9
 * @package   NFePHP\MDFe\IdentifyMDFe
10
 * @copyright Copyright (c) 2008-2015
11
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
12
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
13
 * @link      http://github.com/nfephp-org/nfephp for the canonical source repository
14
 */
15
16
use \DOMDocument;
17
use NFePHP\Common\Identify\Identify as Id;
18
19
class Identify
20
{
21 3
    public static function identificar($xml = '', &$aResp = array())
22
    {
23
        $aList = array(
24 3
            'consReciMDFe' => 'consReciMDFe',
25 2
            'consSitMDFe' => 'consSitMDFe',
26 2
            'consStatServMDFe' => 'consStatServMDFe',
27 2
            'enviMDFe' => 'enviMDFe',
28 2
            'evCancMDFe' => 'evCancMDFe',
29 2
            'evEncMDFe' => 'evEncMDFe',
30 2
            'MDFe' => 'mdfe',
31 2
            'eventoMDFe' => 'eventoMDFe',
32 2
            'procEventoMDFe' => 'procEventoMDFe',
33 2
            'mdfeProc' => 'procMDFe',
34 2
            'retConsReciMDFe' => 'retConsReciMDFe',
35 2
            'retConsSitMDFe' => 'retConsSitMDFe',
36 2
            'retConsStatServMDFe' => 'retConsStatServMDFe',
37 2
            'retEnviMDFe' => 'retEnviMDFe',
38
            'retEventoMDFe' => 'retEventoMDFe'
39 2
        );
40 3
        Id::setListSchemesId($aList);
41 3
        $schem = Id::identificacao($xml, $aResp);
42 3
        $dom = $aResp['dom'];
43 3
        $node = $dom->getElementsByTagName($aResp['tag'])->item(0);
44 3
        if ($schem == 'mdfe') {
45
            //se for um nfe então é necessário pegar a versão
46
            // em outro node infNFe
47 3
            $node1 = $dom->getElementsByTagName('infMDFe')->item(0);
48 3
            $versao = $node1->getAttribute('versao');
49 2
        } else {
50
            $versao = $node->getAttribute('versao');
51 2
        }
52 3
        $aResp['versao'] = $versao;
53 3
        $aResp['xml'] = $dom->saveXML($node);
54 3
        return $schem;
55
    }
56
}
57