Failed Conditions
Push — develop ( 05bf6b...a342cf )
by Reüel
03:02
created

src/Address.php (1 issue)

1
<?php
2
/**
3
 * Address
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\OmniKassa2
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
/**
14
 * Address
15
 *
16
 * @author  Remco Tolsma
17
 * @version 2.1.0
18
 * @since   2.0.2
19
 */
20
class Address {
21
	/**
22
	 * City.
23
	 *
24
	 * @var string|null
25
	 */
26
	private $city;
27
28
	/**
29
	 * Country.
30
	 *
31
	 * @var string
32
	 */
33
	private $country;
34
35
	/**
36
	 * House number or name.
37
	 *
38
	 * @var string|null
39
	 */
40
	private $house_number_or_name;
41
42
	/**
43
	 * Postal code.
44
	 *
45
	 * @var string|null
46
	 */
47
	private $postal_code;
48
49
	/**
50
	 * State or province.
51
	 *
52
	 * @var string|null
53
	 */
54
	private $state_or_province;
55
56
	/**
57
	 * Construct address.
58
	 *
59
	 * @param string $country Country.
60
	 */
61
	public function __construct( $country ) {
62
		$this->set_country( $country );
63
	}
64
65
	/**
66
	 * Get city.
67
	 *
68
	 * @return string|null
69
	 */
70
	public function get_city() {
71
		return $this->city;
72
	}
73
74
	/**
75
	 * Set city.
76
	 *
77
	 * @param string|null $city City.
78
	 */
79
	public function set_city( $city ) {
80
		$this->city = $city;
81
	}
82
83
	/**
84
	 * Get country.
85
	 *
86
	 * @return string
87
	 */
88
	public function get_country() {
89
		return $this->country;
90
	}
91
92
	/**
93
	 * Set country.
94
	 *
95
	 * @param string $country Country.
96
	 */
97
	public function set_country( $country ) {
98
		$this->country = $country;
99
	}
100
101
	/**
102
	 * Get house number or name.
103
	 *
104
	 * @return string|null
105
	 */
106
	public function get_house_number_or_name() {
107
		return $this->house_number_or_name;
108
	}
109
110
	/**
111
	 * Set house number or name.
112
	 *
113
	 * @param string|null $house_number_or_name House number or name.
114
	 */
115
	public function set_house_number_or_name( $house_number_or_name ) {
116
		$this->house_number_or_name = $house_number_or_name;
117
	}
118
119
	/**
120
	 * Get postal code.
121
	 *
122
	 * @return string|null
123
	 */
124
	public function get_postal_code() {
125
		return $this->postal_code;
126
	}
127
128
	/**
129
	 * Set postal code.
130
	 *
131
	 * @param string|null $ostal_code Postal code.
132
	 */
133
	public function set_postal_code( $postal_code ) {
134
		$this->postal_code = $postal_code;
135
	}
136
137
	/**
138
	 * Get state or province.
139
	 *
140
	 * @return string|null
141
	 */
142
	public function get_state_or_province() {
143
		return $this->state_or_province;
144
	}
145
146
	/**
147
	 * Set state or province.
148
	 *
149
	 * @param string|null $state_or_province State or province.
150
	 */
151
	public function set_state_or_province( $state_or_province ) {
152
		$this->state_or_province = $state_or_province;
153
	}
154
155
	/**
156
	 * Get street.
157
	 *
158
	 * @return string|null
159
	 */
160
	public function get_street() {
161
		return $this->street;
162
	}
163
164
	/**
165
	 * Set street.
166
	 *
167
	 * @param string|null $street Street.
168
	 */
169
	public function set_street( $street ) {
170
		$this->street = $street;
0 ignored issues
show
Bug Best Practice introduced by
The property street does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
171
	}
172
173
	/**
174
	 * Get JSON.
175
	 *
176
	 * @return object
177
	 */
178
	public function get_json() {
179
		$object = (object) array();
180
181
		// City.
182
		if ( null !== $this->city ) {
183
			$object->city = $this->city;
184
		}
185
186
		// Country.
187
		$object->country = $this->country;
188
189
		// House number or name.
190
		if ( null !== $this->house_number_or_name ) {
191
			$object->houseNumberOrName = $this->house_number_or_name;
192
		}
193
194
		// Postal code.
195
		if ( null !== $this->postal_code ) {
196
			$object->postalCode = $this->postal_code;
197
		}
198
199
		// State or province.
200
		if ( null !== $this->state_or_province ) {
201
			$object->stateOrProvince = $this->state_or_province;
202
		}
203
204
		// Street.
205
		if ( null !== $this->street ) {
206
			$object->street = $this->street;
207
		}
208
209
		// Return object.
210
		return $object;
211
	}
212
}
213