|
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 string */ |
|
14
|
|
|
private $addressKey; |
|
15
|
|
|
|
|
16
|
|
|
/** @var string */ |
|
17
|
|
|
private $organisationKey; |
|
18
|
|
|
|
|
19
|
|
|
/** @var string */ |
|
20
|
|
|
private $postcodeType; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @return string |
|
24
|
|
|
*/ |
|
25
|
2 |
|
public function getAddressKey() |
|
26
|
|
|
{ |
|
27
|
2 |
|
return $this->addressKey; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param string $addressKey |
|
32
|
|
|
* |
|
33
|
|
|
* @return PafAddressObject |
|
34
|
|
|
*/ |
|
35
|
1 |
|
public function setAddressKey($addressKey) |
|
36
|
|
|
{ |
|
37
|
1 |
|
$this->addressKey = $addressKey; |
|
38
|
|
|
|
|
39
|
1 |
|
return $this; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return string |
|
44
|
|
|
*/ |
|
45
|
2 |
|
public function getOrganisationKey() |
|
46
|
|
|
{ |
|
47
|
2 |
|
return $this->organisationKey; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param string $organisationKey |
|
52
|
|
|
* |
|
53
|
|
|
* @return PafAddressObject |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function setOrganisationKey($organisationKey) |
|
56
|
|
|
{ |
|
57
|
1 |
|
$this->organisationKey = $organisationKey; |
|
58
|
|
|
|
|
59
|
1 |
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
2 |
|
public function getPostcodeType() |
|
66
|
|
|
{ |
|
67
|
2 |
|
return $this->postcodeType; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param string $postcodeType |
|
72
|
|
|
* |
|
73
|
|
|
* @return PafAddressObject |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function setPostcodeType($postcodeType) |
|
76
|
|
|
{ |
|
77
|
1 |
|
$this->postcodeType = $postcodeType; |
|
78
|
|
|
|
|
79
|
1 |
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** {@inheritDoc} */ |
|
83
|
1 |
|
public function jsonSerialize() |
|
84
|
|
|
{ |
|
85
|
|
|
return [ |
|
86
|
1 |
|
'address_key' => $this->getAddressKey(), |
|
87
|
1 |
|
'organisation_key' => $this->getOrganisationKey(), |
|
88
|
1 |
|
'postcode_type' => $this->getPostcodeType(), |
|
89
|
|
|
]; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|