1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ZpgRtf\Objects; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Royal Mail's addressing scheme is known as Postcode Address File (PAF). Many third-party systems use this to |
7
|
|
|
* facilitate the selection of an address from an initial postcode. Per Royal Mail's specification: "Each address on |
8
|
|
|
* PAF® has an eight-digit number associated with it - the Address Key. This number in conjunction with the |
9
|
|
|
* Organisation Key and Postcode Type identifies the address." |
10
|
|
|
*/ |
11
|
|
|
class PafAddressObject implements \JsonSerializable |
12
|
|
|
{ |
13
|
|
|
/** @var null|string */ |
14
|
|
|
private $addressKey; |
15
|
|
|
|
16
|
|
|
/** @var null|string */ |
17
|
|
|
private $organisationKey; |
18
|
|
|
|
19
|
|
|
/** @var null|string */ |
20
|
|
|
private $postcodeType; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @return null|string |
24
|
|
|
*/ |
25
|
3 |
|
public function getAddressKey() |
26
|
|
|
{ |
27
|
3 |
|
return $this->addressKey; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param string $addressKey |
32
|
|
|
* |
33
|
|
|
* @return PafAddressObject |
34
|
|
|
*/ |
35
|
2 |
|
public function setAddressKey(string $addressKey): self |
36
|
|
|
{ |
37
|
2 |
|
$this->addressKey = $addressKey; |
38
|
|
|
|
39
|
2 |
|
return $this; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return null|string |
44
|
|
|
*/ |
45
|
3 |
|
public function getOrganisationKey() |
46
|
|
|
{ |
47
|
3 |
|
return $this->organisationKey; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param string $organisationKey |
52
|
|
|
* |
53
|
|
|
* @return PafAddressObject |
54
|
|
|
*/ |
55
|
2 |
|
public function setOrganisationKey(string $organisationKey): self |
56
|
|
|
{ |
57
|
2 |
|
$this->organisationKey = $organisationKey; |
58
|
|
|
|
59
|
2 |
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return null|string |
64
|
|
|
*/ |
65
|
3 |
|
public function getPostcodeType() |
66
|
|
|
{ |
67
|
3 |
|
return $this->postcodeType; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $postcodeType |
72
|
|
|
* |
73
|
|
|
* @return PafAddressObject |
74
|
|
|
*/ |
75
|
2 |
|
public function setPostcodeType(string $postcodeType): self |
76
|
|
|
{ |
77
|
2 |
|
$this->postcodeType = $postcodeType; |
78
|
|
|
|
79
|
2 |
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** {@inheritDoc} */ |
83
|
2 |
|
public function jsonSerialize(): array |
84
|
|
|
{ |
85
|
2 |
|
return array_filter([ |
86
|
2 |
|
'address_key' => $this->getAddressKey(), |
87
|
2 |
|
'organisation_key' => $this->getOrganisationKey(), |
88
|
2 |
|
'postcode_type' => $this->getPostcodeType(), |
89
|
|
|
]); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|