PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 3.8.1
WooCommerce Square v3.8.1
5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / Framework / Addresses / Address.php
woocommerce-square / includes / Framework / Addresses Last commit date
Address.php 3 years ago Customer_Address.php 3 years ago
Address.php
284 lines
1 <?php
2 /**
3 * WooCommerce Plugin Framework
4 *
5 * This source file is subject to the GNU General Public License v3.0
6 * that is bundled with this package in the file license.txt.
7 * It is also available through the world-wide-web at this URL:
8 * http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
9 * If you did not receive a copy of the license and are unable to
10 * obtain it through the world-wide-web, please send an email
11 * to license@skyverge.com so we can send you a copy immediately.
12 *
13 * @since 3.0.0
14 * @author WooCommerce / SkyVerge
15 * @copyright Copyright (c) 2021-2022, WooCommerce.
16 * @copyright Copyright (c) 2013-2019, SkyVerge, Inc.
17 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
18 *
19 * Modified by WooCommerce on 01 December 2021.
20 */
21
22 namespace WooCommerce\Square\Framework\Addresses;
23
24 defined( 'ABSPATH' ) or exit;
25
26 /**
27 * The base address data class.
28 *
29 * This serves as a standard address object to be passed around by plugins whenever dealing with address data, and
30 * eliminates the need to rely on WooCommerce's address arrays.
31 *
32 * @since 3.0.0
33 */
34 class Address {
35
36
37 /** @var string line 1 of the street address */
38 protected $line_1 = '';
39
40 /** @var string line 2 of the street address */
41 protected $line_2 = '';
42
43 /** @var string line 3 of the street address */
44 protected $line_3 = '';
45
46 /** @var string address locality (city) */
47 protected $locality = '';
48
49 /** @var string address region (state) */
50 protected $region = '';
51
52 /** @var string address country */
53 protected $country = '';
54
55 /** @var string address postcode */
56 protected $postcode = '';
57
58
59 /** Getter methods ************************************************************************************************/
60
61
62 /**
63 * Gets line 1 of the street address.
64 *
65 * @since 3.0.0
66 *
67 * @return string
68 */
69 public function get_line_1() {
70
71 return $this->line_1;
72 }
73
74
75 /**
76 * Gets line 2 of the street address.
77 *
78 * @since 3.0.0
79 *
80 * @return string
81 */
82 public function get_line_2() {
83
84 return $this->line_2;
85 }
86
87
88 /**
89 * Gets line 3 of the street address.
90 *
91 * @since 3.0.0
92 *
93 * @return string
94 */
95 public function get_line_3() {
96
97 return $this->line_3;
98 }
99
100
101 /**
102 * Gets the locality or city.
103 *
104 * @since 3.0.0
105 *
106 * @return string
107 */
108 public function get_locality() {
109
110 return $this->locality;
111 }
112
113
114 /**
115 * Gets the region or state.
116 *
117 * @since 3.0.0
118 *
119 * @return string
120 */
121 public function get_region() {
122
123 return $this->region;
124 }
125
126
127 /**
128 * Gets the country.
129 *
130 * @since 3.0.0
131 *
132 * @return string
133 */
134 public function get_country() {
135
136 return $this->country;
137 }
138
139
140 /**
141 * Gets the postcode.
142 *
143 * @since 3.0.0
144 *
145 * @return string
146 */
147 public function get_postcode() {
148
149 return $this->postcode;
150 }
151
152
153 /**
154 * Gets the hash representation of this address.
155 *
156 * @see Address::get_hash_data()
157 *
158 * @since 3.0.0
159 *
160 * @return string
161 */
162 public function get_hash() {
163
164 return md5( wp_json_encode( $this->get_hash_data() ) );
165 }
166
167
168 /**
169 * Gets the data used to generate a hash for the address.
170 *
171 * @since 3.0.0
172 *
173 * @return string[]
174 */
175 protected function get_hash_data() {
176
177 return array(
178 $this->get_line_1(),
179 $this->get_line_2(),
180 $this->get_line_3(),
181 $this->get_locality(),
182 $this->get_region(),
183 $this->get_country(),
184 $this->get_postcode(),
185 );
186 }
187
188
189 /** Setter methods ************************************************************************************************/
190
191
192 /**
193 * Sets line 1 of the street address.
194 *
195 * @since 3.0.0
196 *
197 * @param string $value line 1 value
198 */
199 public function set_line_1( $value ) {
200
201 $this->line_1 = $value;
202 }
203
204
205 /**
206 * Sets line 2 of the street address.
207 *
208 * @since 3.0.0
209 *
210 * @param string $value line 2 value
211 */
212 public function set_line_2( $value ) {
213
214 $this->line_2 = $value;
215 }
216
217
218 /**
219 * Gets line 3 of the street address.
220 *
221 * @since 3.0.0
222 *
223 * @param string $value line 3 value
224 */
225 public function set_line_3( $value ) {
226
227 $this->line_3 = $value;
228 }
229
230
231 /**
232 * Gets the locality or city.
233 *
234 * @since 3.0.0
235 *
236 * @param string $value locality value
237 */
238 public function set_locality( $value ) {
239
240 $this->locality = $value;
241 }
242
243
244 /**
245 * Gets the region or state.
246 *
247 * @since 3.0.0
248 *
249 * @param string $value region value
250 */
251 public function set_region( $value ) {
252
253 $this->region = $value;
254 }
255
256
257 /**
258 * Sets the country.
259 *
260 * @since 3.0.0
261 *
262 * @param string $value country value
263 */
264 public function set_country( $value ) {
265
266 $this->country = $value;
267 }
268
269
270 /**
271 * Sets the postcode.
272 *
273 * @since 3.0.0
274 *
275 * @param string $value postcode value
276 */
277 public function set_postcode( $value ) {
278
279 $this->postcode = $value;
280 }
281
282
283 }
284