Failed Conditions
Push — feature/post-pay ( d719f9 )
by Reüel
08:19
created

Address::set_postal_code()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Address
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\OmniKassa2
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2;
12
13
/**
14
 * Address
15
 *
16
 * @author  Remco Tolsma
17
 * @version 2.0.2
18
 * @since   2.0.2
19
 */
20
class Address {
21
	/**
22
	 * First name.
23
	 *
24
	 * @var string
25
	 */
26
	private $first_name;
27
28
	/**
29
	 * Insert or second name.
30
	 *
31
	 * @var string
32
	 */
33
	private $middle_name;
34
35
	/**
36
	 * Surname.
37
	 *
38
	 * @var string
39
	 */
40
	private $last_name;
41
42
	/**
43
	 * Street.
44
	 *
45
	 * Note: In case of payment via Visa, Mastercard, V PAY,
46
	 * Bancontact and Maestro the street name will be
47
	 * truncated to 50 characters.
48
	 *
49
	 * @var string
50
	 */
51
	private $street;
52
53
	/**
54
	 * House number.
55
	 *
56
	 * Note: In case of payment via Visa, Mastercard, V PAY,
57
	 * Bancontact and Maestro the houseNumber concatenated
58
	 * with houseNumberAddition (see below) will be
59
	 * truncated to 10 characters.
60
	 *
61
	 * @var string
62
	 */
63
	private $house_number;
64
65
	/**
66
	 * House number additions.
67
	 *
68
	 * @var string
69
	 */
70
	private $house_number_addition;
71
72
	/**
73
	 * Postal code.
74
	 *
75
	 * @var string
76
	 */
77
	private $postal_code;
78
79
	/**
80
	 * City.
81
	 *
82
	 * @var string
83
	 */
84
	private $city;
85
86
	/**
87
	 * Country code, ISO 3166-1 alpha-2.
88
	 *
89
	 * @var string
90
	 */
91
	private $country_code;
92
93
	/**
94
	 * Get first name.
95
	 *
96
	 * @return string
97
	 */
98
	public function get_first_name() {
99
		return $this->first_name;
100
	}
101
102
	/**
103
	 * Set first name.
104
	 *
105
	 * @param string $first_name First name.
106
	 */
107
	public function set_first_name( $first_name ) {
108
		$this->first_name = $first_name;
109
	}
110
111
	/**
112
	 * Get middle name.
113
	 *
114
	 * @return string
115
	 */
116
	public function get_middle_name() {
117
		return $this->middle_name;
118
	}
119
120
	/**
121
	 * Set middle name.
122
	 *
123
	 * @param string $middle_name Middle name.
124
	 */
125
	public function set_middle_name( $middle_name ) {
126
		$this->middle_name = $middle_name;
127
	}
128
129
	/**
130
	 * Get last name.
131
	 *
132
	 * @return string
133
	 */
134
	public function get_last_name() {
135
		return $this->last_name;
136
	}
137
138
	/**
139
	 * Set last name.
140
	 *
141
	 * @param string $last_name Last name.
142
	 */
143
	public function set_last_name( $last_name ) {
144
		$this->last_name = $last_name;
145
	}
146
147
	/**
148
	 * Get street.
149
	 *
150
	 * @return string
151
	 */
152
	public function get_street() {
153
		return $this->street;
154
	}
155
156
	/**
157
	 * Set street.
158
	 *
159
	 * @param string $street Street.
160
	 */
161
	public function set_street( $street ) {
162
		$this->street = $street;
163
	}
164
165
	/**
166
	 * Get house number.
167
	 *
168
	 * @return string
169
	 */
170
	public function get_house_number() {
171
		return $this->house_number;
172
	}
173
174
	/**
175
	 * Set house number.
176
	 *
177
	 * @param string $house_number House number.
178
	 */
179
	public function set_house_number( $house_number ) {
180
		$this->house_number = $house_number;
181
	}
182
183
	/**
184
	 * Get house number addition.
185
	 *
186
	 * @return string
187
	 */
188
	public function get_house_number_addition() {
189
		return $this->house_number_addition;
190
	}
191
192
	/**
193
	 * Set house number addition.
194
	 *
195
	 * @param string $house_number_addition House number addition.
196
	 */
197
	public function set_house_number_addition( $house_number_addition ) {
198
		$this->house_number_addition = $house_number_addition;
199
	}
200
201
	/**
202
	 * Get postal code.
203
	 *
204
	 * @return string
205
	 */
206
	public function get_postal_code() {
207
		return $this->postal_code;
208
	}
209
210
	/**
211
	 * Set postal code.
212
	 *
213
	 * @param string $postal_code Postal code.
214
	 */
215
	public function set_postal_code( $postal_code ) {
216
		$this->postal_code = $postal_code;
217
	}
218
219
	/**
220
	 * Get city.
221
	 *
222
	 * @return string
223
	 */
224
	public function get_city() {
225
		return $this->city;
226
	}
227
228
	/**
229
	 * Set city.
230
	 *
231
	 * @param string $city City.
232
	 */
233
	public function set_city( $city ) {
234
		$this->city = $city;
235
	}
236
237
	/**
238
	 * Get country code.
239
	 *
240
	 * @return string
241
	 */
242
	public function get_country_code() {
243
		return $this->country_code;
244
	}
245
246
	/**
247
	 * Set country code.
248
	 *
249
	 * @param string $country_code Country code.
250
	 */
251
	public function set_country_code( $country_code ) {
252
		$this->country_code = $country_code;
253
	}
254
255
	/**
256
	 * Get JSON.
257
	 *
258
	 * @return object|null
259
	 */
260
	public function get_json() {
261
		$data = array(
262
			'firstName'           => $this->first_name,
263
			'middleName'          => $this->middle_name,
264
			'lastName'            => $this->last_name,
265
			'street'              => $this->street,
266
			'houseNumber'         => $this->house_number,
267
			'houseNumberAddition' => $this->house_number_addition,
268
			'postalCode'          => $this->postal_code,
269
			'city'                => $this->city,
270
			'countryCode'         => $this->country_code,
271
		);
272
273
		$data = array_filter( $data );
274
275
		if ( empty( $data ) ) {
276
			return null;
277
		}
278
279
		return (object) $data;
280
	}
281
282
	/**
283
	 * Get signature data.
284
	 *
285
	 * @return array
286
	 */
287
	public function get_signature_data() {
288
		// Required fields.
289
		$data = array(
290
			$this->first_name,
291
			$this->middle_name,
292
			$this->last_name,
293
			$this->street,
294
		);
295
296
		// Optional house number fields.
297
		if ( null !== $this->house_number ) {
298
			$data[] = $this->house_number;
299
		}
300
301
		if ( null !== $this->house_number_addition ) {
302
			$data[] = $this->house_number_addition;
303
		}
304
305
		// Required fields.
306
		$data[] = $this->postal_code;
307
		$data[] = $this->city;
308
		$data[] = $this->country_code;
309
310
		return $data;
311
	}
312
}
313