Passed
Pull Request — master (#116)
by Carlos C
02:16
created

ComercioExterior::getElementName()   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
namespace CfdiUtils\Elements\Cce20;
4
5
use CfdiUtils\Elements\Common\AbstractElement;
6
7
class ComercioExterior extends AbstractElement
8
{
9 1
    public function getElementName(): string
10
    {
11 1
        return 'cce20:ComercioExterior';
12
    }
13
14 1
    public function getChildrenOrder(): array
15
    {
16 1
        return [
17 1
            'cce20:Emisor',
18 1
            'cce20:Propietario',
19 1
            'cce20:Receptor',
20 1
            'cce20:Destinatario',
21 1
            'cce20:Mercancias',
22 1
        ];
23
    }
24
25 1
    public function getFixedAttributes(): array
26
    {
27 1
        return [
28 1
            'xmlns:cce20' => 'http://www.sat.gob.mx/ComercioExterior20',
29 1
            'xsi:schemaLocation' => 'http://www.sat.gob.mx/ComercioExterior20'
30 1
                . ' http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior20/ComercioExterior20.xsd',
31 1
            'Version' => '2.0',
32 1
        ];
33
    }
34
35 1
    public function getEmisor(): Emisor
36
    {
37 1
        return $this->helperGetOrAdd(new Emisor());
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->helperGetO...lements\Cce20\Emisor()) could return the type CfdiUtils\Elements\Cce20\ComercioExterior which is incompatible with the type-hinted return CfdiUtils\Elements\Cce20\Emisor. Consider adding an additional type-check to rule them out.
Loading history...
38
    }
39
40 1
    public function addEmisor(array $attributes = []): Emisor
41
    {
42 1
        $subject = $this->getEmisor();
43 1
        $subject->addAttributes($attributes);
44 1
        return $subject;
45
    }
46
47 1
    public function addPropietario(array $attributes = []): Propietario
48
    {
49 1
        $subject = new Propietario($attributes);
50 1
        $this->addChild($subject);
51 1
        return $subject;
52
    }
53
54 1
    public function multiPropietario(array ...$elementAttributes): self
55
    {
56 1
        foreach ($elementAttributes as $attributes) {
57 1
            $this->addPropietario($attributes);
58
        }
59 1
        return $this;
60
    }
61
62 1
    public function getReceptor(): Receptor
63
    {
64 1
        return $this->helperGetOrAdd(new Receptor());
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->helperGetO...ments\Cce20\Receptor()) could return the type CfdiUtils\Elements\Cce20\ComercioExterior which is incompatible with the type-hinted return CfdiUtils\Elements\Cce20\Receptor. Consider adding an additional type-check to rule them out.
Loading history...
65
    }
66
67 1
    public function addReceptor(array $attributes = []): Receptor
68
    {
69 1
        $subject = $this->getReceptor();
70 1
        $subject->addAttributes($attributes);
71 1
        return $subject;
72
    }
73
74 1
    public function addDestinatario(array $attributes = []): Destinatario
75
    {
76 1
        $subject = new Destinatario($attributes);
77 1
        $this->addChild($subject);
78 1
        return $subject;
79
    }
80
81 1
    public function multiDestinatario(array ...$elementAttributes): self
82
    {
83 1
        foreach ($elementAttributes as $attributes) {
84 1
            $this->addDestinatario($attributes);
85
        }
86 1
        return $this;
87
    }
88
89 1
    public function getMercancias(): Mercancias
90
    {
91 1
        return $this->helperGetOrAdd(new Mercancias());
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->helperGetO...nts\Cce20\Mercancias()) could return the type CfdiUtils\Elements\Cce20\ComercioExterior which is incompatible with the type-hinted return CfdiUtils\Elements\Cce20\Mercancias. Consider adding an additional type-check to rule them out.
Loading history...
92
    }
93
94 1
    public function addMercancias(array $attributes = []): Mercancias
95
    {
96 1
        $subject = $this->getMercancias();
97 1
        $subject->addAttributes($attributes);
98 1
        return $subject;
99
    }
100
}
101