|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Bpost\BpostApiClient\Bpost\Order; |
|
5
|
|
|
|
|
6
|
|
|
use Bpost\BpostApiClient\Common\XmlHelper; |
|
7
|
|
|
use DOMDocument; |
|
8
|
|
|
use DOMElement; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* bPost PugoAddress class |
|
12
|
|
|
* |
|
13
|
|
|
* @author Tijs Verkoyen <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class PugoAddress extends Address |
|
16
|
|
|
{ |
|
17
|
|
|
public const TAG_NAME = 'pugoAddress'; |
|
18
|
|
|
|
|
19
|
|
|
public function toXML(DOMDocument $document, ?string $prefix = 'common'): DOMElement |
|
20
|
|
|
{ |
|
21
|
|
|
// <national:pugoAddress> |
|
22
|
|
|
$el = $document->createElement( |
|
23
|
|
|
XmlHelper::getPrefixedTagName(self::TAG_NAME, 'national') |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
|
|
// Enfants en "common:*" |
|
27
|
|
|
if ($this->getStreetName() !== null) { |
|
28
|
|
|
$el->appendChild($document->createElement( |
|
29
|
|
|
XmlHelper::getPrefixedTagName('streetName', 'common'), |
|
30
|
|
|
$this->getStreetName() |
|
31
|
|
|
)); |
|
32
|
|
|
} |
|
33
|
|
|
if ($this->getNumber() !== null) { |
|
34
|
|
|
$el->appendChild($document->createElement( |
|
35
|
|
|
XmlHelper::getPrefixedTagName('number', 'common'), |
|
36
|
|
|
$this->getNumber() |
|
37
|
|
|
)); |
|
38
|
|
|
} |
|
39
|
|
|
if ($this->getBox() !== null) { |
|
40
|
|
|
$el->appendChild($document->createElement( |
|
41
|
|
|
XmlHelper::getPrefixedTagName('box', 'common'), |
|
42
|
|
|
$this->getBox() |
|
43
|
|
|
)); |
|
44
|
|
|
} |
|
45
|
|
|
if ($this->getPostalCode() !== null) { |
|
46
|
|
|
$el->appendChild($document->createElement( |
|
47
|
|
|
XmlHelper::getPrefixedTagName('postalCode', 'common'), |
|
48
|
|
|
$this->getPostalCode() |
|
49
|
|
|
)); |
|
50
|
|
|
} |
|
51
|
|
|
if ($this->getLocality() !== null) { |
|
52
|
|
|
$el->appendChild($document->createElement( |
|
53
|
|
|
XmlHelper::getPrefixedTagName('locality', 'common'), |
|
54
|
|
|
$this->getLocality() |
|
55
|
|
|
)); |
|
56
|
|
|
} |
|
57
|
|
|
if ($this->getCountryCode() !== null) { |
|
58
|
|
|
$el->appendChild($document->createElement( |
|
59
|
|
|
XmlHelper::getPrefixedTagName('countryCode', 'common'), |
|
60
|
|
|
$this->getCountryCode() |
|
61
|
|
|
)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $el; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|