Test Setup Failed
Push — master ( 4c62c0...259020 )
by Bruce Pinheiro de
02:12
created

Address::setRegionId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace BPCI\SumUp\Customer;
4
5
/**
6
 * Class Address
7
 * @package BPCI\SumUp\Customer
8
 */
9
class Address implements AddressInterface
10
{
11
	/**
12
	 * First address line
13
	 *
14
	 * @var string $line1
15
	 */
16
	protected $line1;
17
	/**
18
	 * Second address line
19
	 *
20
	 * @var string
21
	 */
22
	protected $line2;
23
	/**
24
	 * Address Country
25
	 *
26
	 * @var string
27
	 */
28
	protected $country;
29
	/**
30
	 * Address postal code
31
	 *
32
	 * @var string
33
	 */
34
	protected $postalCode;
35
	/**
36
	 * Address City
37
	 *
38
	 * @var string
39
	 */
40
	protected $city;
41
	/**
42
	 * @var string
43
	 */
44
	protected $countryEnName;
45
	/**
46
	 * @var string
47
	 */
48
	protected $countryNativeName;
49
	/**
50
	 * @var integer
51
	 */
52
	protected $regionId;
53
	/**
54
	 * @var string
55
	 */
56
	protected $regionName;
57
	/**
58
	 * @var string
59
	 */
60
	protected $postCode;
61
	/**
62
	 * @var string
63
	 */
64
	protected $landline;
65
	/**
66
	 * @var string
67
	 */
68
	protected $addressLine1;
69
	/**
70
	 * @var string
71
	 */
72
	protected $addressLine2;
73
	/**
74
	 * Address State
75
	 *
76
	 * @var string
77
	 */
78
	protected $state;
79
80
	/**
81
	 * Address constructor.
82
	 * @param array|null $data
83
	 */
84
	function __construct(?array $data = [])
85
	{
86
		$this->setAddressLine1($data['address_line1']??null);
87
		$this->setAddressLine2($data['address_line2']??null);
88
		$this->setCity($data['city']??null);
89
		$this->setCountry($data['country']??null);
90
		$this->setCountryEnName($data['country_en_name']??null);
91
		$this->setCountryNativeName($data['country_native_name']??null);
92
		$this->setRegionId($data['region_id']??null);
93
		$this->setRegionName($data['region_name']??null);
94
		$this->setPostCode($data['post_code']??null);
95
		$this->setLandline($data['landline']??null);
96
		$this->setLine1($data['line1']??null);
97
		$this->setLine2($data['line2']??null);
98
		$this->setPostalCode($data['postal_code']??null);
99
		$this->setState($data['state']??null);
100
	}
101
102
	/**
103
	 * Get $line1
104
	 *
105
	 * @return  string
106
	 */
107
	public function getLine1(): ?string
108
	{
109
		return $this->line1;
110
	}
111
112
	/**
113
	 * Set $line1
114
	 *
115
	 * @param  string  $line1  $line1
116
	 *
117
	 * @return  AddressInterface
118
	 */
119
	public function setLine1(?string $line1): AddressInterface
120
	{
121
		$this->line1 = $line1;
122
123
		return $this;
124
	}
125
126
	/**
127
	 * Get second address line
128
	 *
129
	 * @return  string
130
	 */
131
	public function getLine2(): ?string
132
	{
133
		return $this->line2;
134
	}
135
136
	/**
137
	 * Set second address line
138
	 *
139
	 * @param  string  $line2  Second address line
140
	 *
141
	 * @return  AddressInterface
142
	 */
143
	public function setLine2(?string $line2): AddressInterface
144
	{
145
		$this->line2 = $line2;
146
147
		return $this;
148
	}
149
150
	/**
151
	 * Get address Country
152
	 *
153
	 * @return  string
154
	 */
155
	public function getCountry(): ?string
156
	{
157
		return $this->country;
158
	}
159
160
	/**
161
	 * Set address Country
162
	 *
163
	 * @param  string  $country  Address Country
164
	 *
165
	 * @return  AddressInterface
166
	 */
167
	public function setCountry(?string $country): AddressInterface
168
	{
169
		$this->country = $country;
170
171
		return $this;
172
	}
173
174
	/**
175
	 * Get address postal code
176
	 *
177
	 * @return  string
178
	 */
179
	public function getPostalCode(): ?string
180
	{
181
		return $this->postalCode;
182
	}
183
184
	/**
185
	 * Set address postal code
186
	 *
187
	 * @param  string  $postalCode  Address postal code
188
	 *
189
	 * @return  AddressInterface
190
	 */
191
	public function setPostalCode(?string $postalCode): AddressInterface
192
	{
193
		$this->postalCode = $postalCode;
194
195
		return $this;
196
	}
197
198
	/**
199
	 * Get address City
200
	 *
201
	 * @return  string
202
	 */
203
	public function getCity(): ?string
204
	{
205
		return $this->city;
206
	}
207
208
	/**
209
	 * Set address City
210
	 *
211
	 * @param  string  $city  Address City
212
	 *
213
	 * @return  AddressInterface
214
	 */
215
	public function setCity(?string $city): AddressInterface
216
	{
217
		$this->city = $city;
218
219
		return $this;
220
	}
221
222
	/**
223
	 * @return mixed
224
	 */
225
	public function getCountryEnName():? string
226
	{
227
		return $this->countryEnName;
228
	}
229
230
	/**
231
	 * @param mixed $countryEnName
232
	 * @return AddressInterface
233
	 */
234
	public function setCountryEnName($countryEnName): AddressInterface
235
	{
236
		$this->countryEnName = $countryEnName;
237
238
		return $this;
239
	}
240
241
	/**
242
	 * @return mixed
243
	 */
244
	public function getCountryNativeName():? string
245
	{
246
		return $this->countryNativeName;
247
	}
248
249
	/**
250
	 * @param mixed $countryNativeName
251
	 * @return Address
252
	 */
253
	public function setCountryNativeName(?string $countryNativeName): AddressInterface
254
	{
255
		$this->countryNativeName = $countryNativeName;
256
257
		return $this;
258
	}
259
260
	/**
261
	 * @return number|null
262
	 */
263
	public function getRegionId():? number
0 ignored issues
show
Bug introduced by
The type BPCI\SumUp\Customer\number was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
264
	{
265
		return $this->regionId;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->regionId returns the type integer which is incompatible with the type-hinted return null|BPCI\SumUp\Customer\number.
Loading history...
266
	}
267
268
	/**
269
	 * @param number|null $regionId
270
	 * @return Address
271
	 */
272
	public function setRegionId(?number $regionId): AddressInterface
273
	{
274
		$this->regionId = $regionId;
0 ignored issues
show
Documentation Bug introduced by
It seems like $regionId can also be of type BPCI\SumUp\Customer\number. However, the property $regionId is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
275
276
		return $this;
277
	}
278
279
	/**
280
	 * @return string|null
281
	 */
282
	public function getRegionName():? string
283
	{
284
		return $this->regionName;
285
	}
286
287
	/**
288
	 * @param string|null $regionName
289
	 * @return AddressInterface
290
	 */
291
	public function setRegionName(?string $regionName): AddressInterface
292
	{
293
		$this->regionName = $regionName;
294
295
		return $this;
296
	}
297
298
	/**
299
	 * @return string|null
300
	 */
301
	public function getPostCode():? string
302
	{
303
		return $this->postCode;
304
	}
305
306
	/**
307
	 * @param string|null $postCode
308
	 * @return AddressInterface
309
	 */
310
	public function setPostCode(?string $postCode): AddressInterface
311
	{
312
		$this->postCode = $postCode;
313
314
		return $this;
315
	}
316
317
	/**
318
	 * @return string|null
319
	 */
320
	public function getLandline():? string
321
	{
322
		return $this->landline;
323
	}
324
325
	/**
326
	 * @param string|null $landline
327
	 * @return AddressInterface
328
	 */
329
	public function setLandline(?string $landline): AddressInterface
330
	{
331
		$this->landline = $landline;
332
333
		return $this;
334
	}
335
336
	/**
337
	 * @return string|null
338
	 */
339
	public function getAddressLine1():? string
340
	{
341
		return $this->addressLine1;
342
	}
343
344
	/**
345
	 * @param string|null $addressLine1
346
	 * @return AddressInterface
347
	 */
348
	public function setAddressLine1(?string $addressLine1): AddressInterface
349
	{
350
		$this->addressLine1 = $addressLine1;
351
352
		return $this;
353
	}
354
355
	/**
356
	 * @return string|null
357
	 */
358
	public function getAddressLine2():? string
359
	{
360
		return $this->addressLine2;
361
	}
362
363
	/**
364
	 * @param string|null $addressLine2
365
	 * @return AddressInterface
366
	 */
367
	public function setAddressLine2(?string $addressLine2): AddressInterface
368
	{
369
		$this->addressLine2 = $addressLine2;
370
371
		return $this;
372
	}
373
374
	/**
375
	 * Get address State
376
	 *
377
	 * @return  string|null
378
	 */
379
	public function getState(): ?string
380
	{
381
		return $this->state;
382
	}
383
384
	/**
385
	 * Set address State
386
	 *
387
	 * @param  string|null  $state  Address State
388
	 *
389
	 * @return  AddressInterface
390
	 */
391
	public function setState(?string $state): AddressInterface
392
	{
393
		$this->state = $state;
394
395
		return $this;
396
	}
397
}
398