Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jan 7, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddress.php
More file actions
Latest commit
181 lines (159 loc) · 3.13 KB
/
Copy pathAddress.php
File metadata and controls
181 lines (159 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
namespaceDevMob\Postcodes\Address;
useInvalidArgumentException;
class Address
{
/**
* Allowed postcode format.
* Does not validate actual postcodes and is only used to normalise all postcodes used within this package.
*/
publicconstPOSTCODE_FORMAT = '/^(\d{4})([A-Z]{2})$/';
/**
* @var string
*/
private$postcode;
/**
* @var string
*/
private$houseNumber;
/**
* @var string
*/
private$street;
/**
* @var string
*/
private$city;
/**
* @var string
*/
private$province;
/**
* @var string
*/
private$latitude;
/**
* @var string
*/
private$longitude;
/**
* @var array
*/
private$raw;
/**
* Constructor.
*
* @param string $postcode
* @param string $houseNumber
* @param string $street
* @param string $city
* @param string $province
* @param string $latitude
* @param string $longitude
* @param array $raw
*/
publicfunction__construct(
string$postcode,
string$houseNumber,
string$street,
string$city,
string$province,
string$latitude,
string$longitude,
array$raw = []
) {
$this->setPostcode($postcode);
$this->houseNumber = $houseNumber;
$this->street = $street;
$this->city = $city;
$this->province = $province;
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->raw = $raw;
}
/**
* Postcode in '0000AA' format.
*
* @return string
*/
publicfunctiongetPostcode(): string
{
return$this->postcode;
}
/**
* Set postcode.
*
* @param string $postcode
* @return void
*/
protectedfunctionsetPostcode(string$postcode): void
{
if (! preg_match(self::POSTCODE_FORMAT, $postcode)) {
thrownewInvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT);
}
$this->postcode = $postcode;
}
/**
* House number.
*
* @return string
*/
publicfunctiongetHouseNumber(): string
{
return$this->houseNumber;
}
/**
* Street name.
*
* @return string
*/
publicfunctiongetStreet(): string
{
return$this->street;
}
/**
* City.
*
* @return string
*/
publicfunctiongetCity(): string
{
return$this->city;
}
/**
* Province.
*
* @return string
*/
publicfunctiongetProvince(): string
{
return$this->province;
}
/**
* Latitude.
*
* @return string
*/
publicfunctiongetLatitude(): string
{
return$this->latitude;
}
/**
* Longitude.
*
* @return string
*/
publicfunctiongetLongitude(): string
{
return$this->longitude;
}
/**
* Raw address data.
*
* @return array
*/
publicfunctiongetRaw(): array
{
return$this->raw;
}
}