1 | <?php |
||
2 | |||
3 | namespace CfdiUtils; |
||
4 | |||
5 | use CfdiUtils\Internals\XmlReaderTrait; |
||
6 | use DOMDocument; |
||
7 | |||
8 | /** |
||
9 | * This class contains minimum helpers to read CFDI based on DOMDocument |
||
10 | * |
||
11 | * When the object is instantiated it checks that: |
||
12 | * implements the namespace static::CFDI_NAMESPACE using a prefix |
||
13 | * the root node is prefix + Comprobante |
||
14 | * |
||
15 | * This class also provides version information thru getVersion() method |
||
16 | * |
||
17 | * This class also provides conversion to Node for easy access and manipulation, |
||
18 | * changes made in Node structure are not reflected into the DOMDocument, |
||
19 | * changes made in DOMDocument three are not reflected into the Node, |
||
20 | * |
||
21 | * Use this class as your starting point to read documents |
||
22 | */ |
||
23 | class Cfdi |
||
24 | { |
||
25 | use XmlReaderTrait; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
26 | |||
27 | const CFDI_NAMESPACE = 'http://www.sat.gob.mx/cfd/3'; |
||
28 | |||
29 | 51 | public function __construct(DOMDocument $document) |
|
30 | { |
||
31 | 51 | $rootElement = self::checkRootElement($document, static::CFDI_NAMESPACE, 'cfdi', 'Comprobante'); |
|
32 | 46 | $this->document = clone $document; |
|
33 | 46 | $this->version = (new CfdiVersion())->getFromDOMElement($rootElement); |
|
34 | 46 | } |
|
35 | } |
||
36 |