1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Bpost\BpostApiClient\Bpack247; |
5
|
|
|
|
6
|
|
|
use SimpleXMLElement; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* bPost Customer Pack Station class |
10
|
|
|
* |
11
|
|
|
* @author Tijs Verkoyen <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class CustomerPackStation |
14
|
|
|
{ |
15
|
|
|
public function __construct( |
16
|
|
|
private ?string $customLabel = null, |
17
|
|
|
private ?string $orderNumber = null, |
18
|
|
|
private ?string $packstationId = null, |
19
|
|
|
) {} |
20
|
|
|
|
21
|
|
|
public function setCustomLabel(?string $customLabel): void |
22
|
|
|
{ |
23
|
|
|
$this->customLabel = $customLabel; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getCustomLabel(): ?string |
27
|
|
|
{ |
28
|
|
|
return $this->customLabel; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function setOrderNumber(?string $orderNumber): void |
32
|
|
|
{ |
33
|
|
|
$this->orderNumber = $orderNumber; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getOrderNumber(): ?string |
37
|
|
|
{ |
38
|
|
|
return $this->orderNumber; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function setPackstationId(?string $packstationId): void |
42
|
|
|
{ |
43
|
|
|
$this->packstationId = $packstationId; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getPackstationId(): ?string |
47
|
|
|
{ |
48
|
|
|
return $this->packstationId; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public static function createFromXML(SimpleXMLElement $xml): self |
52
|
|
|
{ |
53
|
|
|
$packStation = new self(); |
54
|
|
|
|
55
|
|
|
if (isset($xml->OrderNumber) && (string)$xml->OrderNumber !== '') { |
56
|
|
|
$packStation->setOrderNumber((string)$xml->OrderNumber); |
57
|
|
|
} |
58
|
|
|
if (isset($xml->CustomLabel) && (string)$xml->CustomLabel !== '') { |
59
|
|
|
$packStation->setCustomLabel((string)$xml->CustomLabel); |
60
|
|
|
} |
61
|
|
|
if (isset($xml->PackstationID) && (string)$xml->PackstationID !== '') { |
62
|
|
|
$packStation->setPackstationId((string)$xml->PackstationID); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $packStation; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|